背景透明色
Background transparent color
我想像 youtube 一样在滑出式菜单中制作透明色,有什么想法吗?
请帮忙!
您可以使用 iOS 8 默认 UIVisualEffect
和 UIVisualEffectView
轻松添加模糊效果确保它仅在 [=23 以上可用=] 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)
试试这个:
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/
我想像 youtube 一样在滑出式菜单中制作透明色,有什么想法吗? 请帮忙!
您可以使用 iOS 8 默认 UIVisualEffect
和 UIVisualEffectView
轻松添加模糊效果确保它仅在 [=23 以上可用=] 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)
试试这个:
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/