I'm coding a custom keyboard and i want to customize the height.. Apple Documentation give that code only in Objective-C, does anyone know how to write it in Swift Language? This is the code from Apple:
CGFloat _expandedHeight = 500;
NSLayoutConstraint *_heightConstraint =
[NSLayoutConstraint constraintWithItem: self.view
attribute: NSLayoutAttributeHeight
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 0.0
constant: _expandedHeight];
[self.view addConstraint: _heightConstraint];
I tried to write it like this but it doesn't do anything..:
override func viewDidAppear(animated:Bool) {
super.viewDidAppear(true)
let nib = UINib(nibName: "KeyboardView", bundle: nil)
let objects = nib.instantiateWithOwner(self, options: nil)
view = objects[0] as UIView;
let _viewHeight: CGFloat = 256
let const1 = NSLayoutConstraint(
item:self.view, attribute:.Height,
relatedBy:.Equal, toItem:nil,
attribute:.NotAnAttribute,multiplier:0, constant: _viewHeight)
view.addConstraint(const1)
}
Help me please!