Ios 背景透明色
我想在我的幻灯片菜单中使用透明的颜色,比如youtube,有什么想法吗?Ios 背景透明色,ios,swift,Ios,Swift,我想在我的幻灯片菜单中使用透明的颜色,比如youtube,有什么想法吗? 请帮忙 您可以使用iOS 8默认UIVisualEffect和UIVisualEffectView轻松添加模糊效果,确保其仅在iOS 8以上可用 UIVisualEffect *blurV = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; UIVisualEffectView *visualV = [[UIVisualEffectView alloc] init
请帮忙 您可以使用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);
斯威夫特
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
}
希望这对你有帮助。你也可以看看这篇博客文章:
谢谢你的回复,先生。你能用swift写一些例子吗?因为我是swift的新手。对我来说,你的syantax看起来像objc或奇怪。谢谢你的回复。但是,我仍然不知道把你的代码放在哪里。在我的viewDidLoad()中,我放了“self.view.backgroundColor=UIColor(patternImage:UIImage(名为:“LeftMenu_2.jpg”)!”现在就看这个图像。@Thiha6245获取一个UIImageView并将其添加到xib中。把它放出去。然后在ViewDidDisplay中添加以下代码。您还可以使用直接添加
UIVisualEffectView
<代码>self.view.addSubview(visualV)