nslayoutconstraint

Understanding “firstBaseLine” vs. “baseLine” AutoLayout Constraint

最后都变了- 提交于 2019-12-21 07:23:22
问题 I've created the following view that looks as follow: And used Add missing constraints t automatically add constraints. I am pretty new in iOS world and I'm trying to configure out how constraints work. On document outline, I can see the added constraints: I click on label UR and Size inspector show me following: What is the difference between constraints aligned by first baseline to UL and aligned by baseline to UL? When I click on the size inspector on constraints button, it shows me the

Auto Layout Constraint With Dynamic Variable?

一曲冷凌霜 提交于 2019-12-21 05:37:13
问题 Is it possible to have an Auto Layout constraint ( NSLayoutConstraint ) with a dynamic constant/multiplier? For example, this would be a bog standard NSLayoutConstraint : NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:obj1 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:obj2 attribute:NSLayoutAttributeLeft multiplier:1 constant:0]; Then here would be an alteration of that constraint but a dynamic variable in the constant: NSLayoutConstraint

Handling AutoLayout constraint animation differences in iOS 10?

馋奶兔 提交于 2019-12-21 03:11:22
问题 I've noticed that in iOS 10 Beta 5 (about to try Beta 6), AutoLayout constraint animation behaves a bit differently. For example, this approach does not work the same as it did in previous iOS releases: [view addConstraints:@[constraints...]]; [view setNeedsUpdateConstraints]; [view layoutIfNeeded]; [UIView animateWithDuration:... { /* adjust constraint here... */ [view layoutIfNeeded]; // Only the adjusted constraints since previous layoutIfNeeded() call should animate change with duration.

How to change height of UIView that already has height anchor?

让人想犯罪 __ 提交于 2019-12-19 09:28:08
问题 If I have this for a child view controller: autoCompleteViewController.view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ autoCompleteViewController.view.topAnchor.constraint(equalTo: view.topAnchor, constant: 0), autoCompleteViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0), autoCompleteViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0), autoCompleteViewController.view.bottomAnchor

UILabel text not automatically resized using Auto Layout

一曲冷凌霜 提交于 2019-12-18 14:57:07
问题 I'm trying to implement a constrained UITableViewCell subclass and everything is working perfectly, except for the UILabel . The constraints that I've set up are definitely being enforced, but the text inside of the label does not resize to a smaller font size when the constraints clash. Instead, the height of the UILabel gets truncated and the font remains the same size, meaning the letters get cut off at the top and bottom. Is there some method I have to call in order to get this to work? I

Swift 3 Create UILabel programmatically and add NSLayoutConstraints

佐手、 提交于 2019-12-18 13:24:10
问题 Hello I am trying to create a label programmatically and add NSLayoutConstraints so that it is centered in the superview regardless of screen size and orientation etc. I have looked but just can't find an example to follow. Here is what I have: let codedLabel:UILabel = UILabel() codedLabel.frame = CGRect(x: 100, y: 100, width: 200, height: 200) codedLabel.textAlignment = .center codedLabel.text = alertText codedLabel.numberOfLines=1 codedLabel.textColor=UIColor.red codedLabel.font=UIFont

How to change bottom layout constraint in iOS, Swift

做~自己de王妃 提交于 2019-12-18 11:54:00
问题 I have scroll view as @IBOutlet @IBOutlet weak var mainScrollView: UIScrollView! I want to change the "Bottom space to: Bottom Layout Guide" constraint programmatically. First Item : Bottom Layout Guide.Top Relation : Equal Second Item: Scroll View.Bottom Constant: 0 -> 50 // (I want to change this programmatically) Priority: 1000 Multiplier: 1 How can I do this? 回答1: Take the constraint as IBOutlet of NSLayoutConstraint . Set the constraint outlets and change constant value by : self

how can I use one storyboard for 4“ and 3.5” iphone screens with autolayout (ios6 + ios7)?

喜欢而已 提交于 2019-12-18 10:20:25
问题 While there are many questions and answers about building a storyboard layout that would work both on 4" and 3.5" screen sizes, I couldn't find a suitable solution for the following scenario. I use autolayout with ios6 (and ios7), and I don't have to support landscpae or ipad. I have a UIView with several subviews, which have to look as the mockup below. It is easy to set up autolayout constraints in the storyboard to fit either of the screen sizes. My question is - how do I make autolayout

What is the difference between all these Auto Layout update methods? Are all necessary?

陌路散爱 提交于 2019-12-18 09:56:58
问题 In the code below, these four methods are called for layout reasoning. I'm a little confused why all of them are needed, though, and what they do differently from one another. They're used in the process to make a cell's height be dynamic with Auto Layout. (Taken from this repository from this question.) [cell setNeedsUpdateConstraints]; [cell updateConstraintsIfNeeded]; [cell.contentView setNeedsLayout]; [cell.contentView layoutIfNeeded]; And it's from this block of code for the cell's

Programatic Constraints Not Obeyed

淺唱寂寞╮ 提交于 2019-12-18 09:45:40
问题 I run the below code on a button press, however the bottom constraint does not seem to be obeyed. The subview (bandCardView) overflows the bottom of the parent view (formVw). How can I make these constraints obeyed? @objc private func cardBtnTouch(){ self.bandAccountView?.bankBtn.setSelected(selected: false) self.bandAccountView?.cardBtn.setSelected(selected: true) self.bandAccountView?.selectLbl.isHidden = true for subview in self.bandAccountView!.formVw.subviews{ subview.removeFromSuperview