我想在我的幻灯片菜单中制作透明色,如youtube,任何想法? 请帮助!
答案 0 :(得分:2)
您可以使用 iOS 8 默认UIVisualEffect
和UIVisualEffectView
轻松添加模糊效果。确保它仅适用于iOS 8以上。
UIVisualEffect *blurV = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *visualV = [[UIVisualEffectView alloc] initWithEffect:blurV];
visualV.frame = yourImageView.bounds;
[yourImageView addSubview:visualEffectView];
您可以添加三种默认效果之一
typedef NS_ENUM(NSInteger, UIBlurEffectStyle) {
UIBlurEffectStyleExtraLight,
UIBlurEffectStyleLight,
UIBlurEffectStyleDark
} NS_ENUM_AVAILABLE_IOS(8_0);
对于Swift
var visualV = UIVisualEffectView(effect: UIBlurEffect(style: .Dark)) as UIVisualEffectView
visualV.frame = yourImageView.bounds
yourImageView.addSubview(visualV)
答案 1 :(得分:1)
试试这个:
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?
{
println("The indexPath code is \(indexPath!.row)")
let cell = tableView!.dequeueReusableCellWithIdentifier("FlowerTableViewCell", forIndexPath: indexPath) as FlowerTableViewCell
let flower = flowers[indexPath!.row] as Flower
let backgroundImageView = UIImageView(image: UIImage(named: flower.backgroundImage))
cell.backgroundView = backgroundImageView
var visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light)) as UIVisualEffectView
visualEffectView.frame = CGRectMake(0, 0, cell.bounds.width, cell.bounds.height)
backgroundImageView.addSubview(visualEffectView)
cell.textLabel.text = flower.name
cell.textLabel.textColor = UIColor.whiteColor()
cell.textLabel.backgroundColor = UIColor.clearColor()
return cell
}
希望这会对你有所帮助。你也可以看看这篇博客文章: http://blog.bubbly.net/2013/09/11/slick-tricks-for-ios-blur-effect/