LoginSignup
20
18

More than 5 years have passed since last update.

SwiftでUIBlurEffect、曇りガラスエフェクト実装してみた

Posted at

SwiftでUIBlurEffectを実装してみた。

iOS7の登場と共に複数のライブラリが出現した。

iOS8では、動的にぼかしエフェクトを生成できるUIBlurEffectが追加されたため、今後はこれが主流になってくるだろう。

f:id:jeffsuke:20140714093118p:plain

BlurEffectViewController.m
import UIKit

class BlurEffectViewController: UIViewController {

    @IBOutlet var image: UIImageView

    override func viewDidLoad() {
        super.viewDidLoad()

        addBlurEffect()
    }


    func addBlurEffect() {
        var effect = UIBlurEffect(style: UIBlurEffectStyle.Light);
        var effectView = UIVisualEffectView(effect: effect);
        let rect = UIScreen.mainScreen().applicationFrame
        effectView.frame = CGRectMake(0, 0, rect.width, rect.height / 3)

        view.addSubview(effectView);
    }
}
20
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
18