Thursday, August 11, 2022
HomeiOS Developmentios - Visible Impact View's Blur would not work on UIView from...

ios – Visible Impact View’s Blur would not work on UIView from xib


I created a customized Numpad keyboard via xib and wished so as to add a blur impact to its background. So I add a Visible Impact View in xib:

Primary View and Visible Impact View background shade is ready to Default and I additionally tried to make use of Clear Coloration.

The issue is after I initialize the Numpad, background has a lightweight gray shade with none blur impact:

How one can add a blur impact to the Numpad so yellow sq. may be blurred and visual?

Code for NumpadView:

import UIKit

class NumpadView: UIView {

@IBOutlet weak var resetButton: NumpadButton!
@IBOutlet weak var decimalButton: NumpadButton!

var goal: UITextInput?
var view: UIView?

init(goal: UITextInput, view: UIView) {
    tremendous.init(body: .zero)
    self.goal = goal
    self.view = view
    initializeSubview()
}

required init?(coder: NSCoder) {
    tremendous.init(coder: coder)
    initializeSubview()
}

func initializeSubview() {
    let xibFileName = "NumpadView"
    let view = Bundle.most important.loadNibNamed(xibFileName, proprietor: self, choices: nil)![0] as! UIView
    self.addSubview(view)
    view.body = self.bounds
    self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
}
}

Code for initializing in a VC:

import UIKit

class NumpadViewController: UIViewController, UITextFieldDelegate {

@IBOutlet weak var textField: UITextField!

override func viewDidLoad() {
    tremendous.viewDidLoad()
    textField.delegate = self
    textField.inputView = NumpadView(goal: textField, view: view)
}
}

Take a look at challenge on Github

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments