Reputation: 5096
I want to make transparent color in my slide out menu like youtube,any ideas? Please Help!
Upvotes: 1
Views: 857
Reputation: 1192
Try this:
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
}
Hope this helps you. You may also take a look on this blog-article: http://blog.bubbly.net/2013/09/11/slick-tricks-for-ios-blur-effect/
Upvotes: 1
Reputation: 5164
You can add easily blur effect using iOS 8 default UIVisualEffect
and UIVisualEffectView
Make Sure it will only available above iOS 8.
UIVisualEffect *blurV = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *visualV = [[UIVisualEffectView alloc] initWithEffect:blurV];
visualV.frame = yourImageView.bounds;
[yourImageView addSubview:visualEffectView];
You can add one of three default effects
typedef NS_ENUM(NSInteger, UIBlurEffectStyle) {
UIBlurEffectStyleExtraLight,
UIBlurEffectStyleLight,
UIBlurEffectStyleDark
} NS_ENUM_AVAILABLE_IOS(8_0);
For Swift
var visualV = UIVisualEffectView(effect: UIBlurEffect(style: .Dark)) as UIVisualEffectView
visualV.frame = yourImageView.bounds
yourImageView.addSubview(visualV)
Upvotes: 2