【发布时间】:2014-11-18 18:19:00
【问题描述】:
我有一个显示照片的 tableView。 我只想添加一个 subView 以便在单元格顶部产生模糊效果。 我的问题是,当我使用 didSelectRowAtIndex 方法添加子视图时,我的子视图(我的模糊)被添加到重用的单元格中......
这就是我所做的:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell:WallTableViewCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as WallTableViewCell
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = cell.imagePosted.bounds
cell.imagePosted.insertSubview(blurEffectView, atIndex: indexPath.row)
}
有没有办法使用点击识别器添加模糊效果,所以当我点击时会添加模糊,而当我第二次点击时会移除模糊?以及如何仅在被点击的单元格上添加模糊?
【问题讨论】:
标签: ios uitableview swift addsubview