var bgimage = Uiimageview ()
var Backbutton = UIButton ()
var Titlelabel = UILabel ()
Let Screen_h = UIScreen.main.bounds.height
Let Screen_w = UIScreen.main.bounds.width
Override Init (Frame:cgrect) {
Super.init (Frame:frame)
Initui ()
}
Required init? (Coder Adecoder:nscoder) {
FatalError ("Init (coder:) have not been implemented")
}
Func Initui () {
Bgimage.frame=cgrect (x:0,y:0,width:screen_w,height:64)
Bgimage.backgroundcolor = Uicolor (Patternimage:uiimage (named: "NAVBAR_BG")!)
Self.addsubview (Bgimage)
First create a Blur effect
Let Blureffect = Uiblureffect (style:. Dark)
Then create a view that hosts the Blur effect
Let Blurview = Uivisualeffectview (effect:blureffect)
Set the size of the blur view (full screen)
BlurView.frame.size = Cgsize (Width:screen_w, height:64)
Add Blur view to Page view (Blur appears underneath the Blur view)
blurview.alpha=0.7
Self.addsubview (Blurview)
Backbutton = UIButton (type:. Custom)
Backbutton.frame = CGRect (x:0, y:20, width:60, height:44)
Backbutton.backgroundcolor = Uicolor.clear
Backbutton.setimage (UIImage (named: "Btn_return"), for:. Normal)
Self.addsubview (Backbutton)
Titlelabel.frame=cgrect (X:SCREEN_W/2-100,Y:20+44/2-8,WIDTH:200,HEIGHT:18)
Titlelabel.text= "Old Glass"
Titlelabel.textcolor=uicolor.white
titlelabel.textalignment =. Center
Titlelabel.font = Uifont (name: "Arial", size:16.0)
Self.addsubview (Titlelabel)
}
Swift Gaussian blur for custom view