【发布时间】:2018-06-20 09:31:47
【问题描述】:
在表格视图单元格中,我有一个图像和一个按钮,现在我想通过单击按钮来模糊图像
我有以下代码:-
func blurEffect(){
let blur = UIBlurEffect(style: UIBlurEffectStyle.light)
let blurView = UIVisualEffectView(effect: blur)
var imageView = UIImageView()
blurView.frame = imageView.bounds
view.addSubview(blurView)
}
// I am Calling blur effect on at tick button action as below
@objc func tickButton(btn : UIButton){
blurEffect()
}
//In tableView
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = MealTableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! MealCell
cell.imgMeal.image = UIImage(named: mealImage[indexPath.row])
cell.btnTick.addTarget(self, action: #selector(MealPlanViewController.tickButton(btn:)), for: .touchUpInside)
return cell
}
【问题讨论】:
-
你应该把这段代码放在你的
cell类中。不在ViewController。 -
我想飞!!
-
请不要问我要,问你的问题
标签: ios swift uitableview uiblureffect