nslayoutconstraint

Unable to make outlet connection to a constraint in IB

a 夏天 提交于 2019-11-26 04:51:27
问题 I am running XCode 5 with iOS 7. I need to dynamically change the height constraint of a UITextView prior to its layout. I have seen many postings stating that this can be done by making an outlet connection from the constraint in IB to the source code. I am trying to make the connection from the constraint outlet in IB to the header file of the owning class, but am unable to make the connection - IB does not \"highlight\" when I drag over the header file, as it does when making connections

How to add constraints programmatically using Swift

送分小仙女□ 提交于 2019-11-26 01:18:58
问题 I\'m trying to figure this out since last week without going any step further. Ok, so I need to apply some constraints programmatically in Swift to a UIView using this code: var new_view:UIView! = UIView(frame: CGRectMake(0, 0, 100, 100)); new_view.backgroundColor = UIColor.redColor(); view.addSubview(new_view); var constX:NSLayoutConstraint = NSLayoutConstraint(item: new_view, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: