2015-01-21 4 views

ответ

2

Вы можете добавить эффект размытия легко с помощью IOS 8 по умолчанию UIVisualEffect и UIVisualEffectView Убедитесь, что он будет доступен только над прошивкой 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) 
+0

Спасибо за ваш ответ, сэр. Пожалуйста, напишите, пожалуйста, пример в swift? Coz Я новичок в swift.To для меня ваш syantax выглядит как objc или странный , –

+0

@ Thiha6245 проверить мой обновленный ответ. –

+0

Спасибо за ваш ответ. Но я до сих пор не знаю, где разместить свой код. В моем представленииDidLoad() я положил «self.view.backgroundColor = UIColor (patternImage: UIImage (named:« LeftMenu_2.jpg »)!) «этот образ на данный момент. –

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/

Смежные вопросы