nslayoutconstraint

Animate a layout constraint by changing its priority value

十年热恋 提交于 2019-12-11 02:21:53
问题 I have a label containing quite a lot of text. There's a toggle for collapsing and expanding the height of the label (here it's named "lire la suite" ) so it truncates the end of the text. I have meticulously set the vertical content hugging priority and compression resistance so the intrinsic size has higher priority over the compression resistance. The height constraint (the optional constraint directly at the right of the label) is set with a constant of 71 , just the height for 4 lines.

getting NSLayoutConstraints associated view

此生再无相见时 提交于 2019-12-10 18:16:55
问题 I trying to loop through a views constraints. I added to view1: top, trailing, leading and height constraints. top, trailing and leading are to the main ViewControllers view. if i loop through view1's constraints i only see the height constraint. for constraint in view1.constraints { print(constraint) } NSLayoutConstraint:0x6180000968a0 UIView:0x7fae6b409dd0.height == 146 (active) so i looped through its superviews constraints (the ViewControllers main view) and i got lots of constraints some

How can I make it so if I fade my navigation bar out, then actually hide it programmatically, that if I undo this there's no timing issues?

此生再无相见时 提交于 2019-12-10 17:57:11
问题 Long story short, I have a view controller where the user can tap on self.view (anywhere but the nav bar) and it will enter a full screen mode where the controls at the bottom fade out and the navigation and status bar fade out. Similar to iBooks. I could simply fade the alpha of the navigation bar, but as to allow the user to tap in the newly gained area (where the navigation bar was now that it's faded out) and have it do something, I have to do more than change the alpha, as the nav bar is

Scroll hesitation with floating view in UIScrollView using auto layout

早过忘川 提交于 2019-12-10 11:56:36
问题 QUESTION: I'll simplify the question but keep my original for reference... I am modifying the priority of existing constraints, but the result only changes the position of one of the UIScrollView subviews. All remaining subviews maintain their original size and position, yet it looks like I am incurring a layout pass on all subviews below the one I am modifying constraints on. So, why is ViewWillLayoutSubviews and UpdateViewConstraints being called on things that haven't changed? [Original

Subclassing NSLayoutConstraint constant based on screen height

僤鯓⒐⒋嵵緔 提交于 2019-12-10 10:14:29
问题 I have a project with a Tab Bar, and a custom Navigation bar for each of the tabs. Each of the Navigation bar UIViews have a height constraint constant set in the storyboard. I would like to subclass this NSLayoutConstraint (for the Nav height), so that it changes the height for iPhone X. The Navigation bar needs to be much taller on an iPhone X, and since I'm not using "out of the box" objects, my constraints need to be manually set. Essentially, I want to do something like the following in

Keep UIButtons centered using autolayout in storyboard

霸气de小男生 提交于 2019-12-10 04:36:49
问题 I have two buttons contained within a view (to be precise, a UITableView footer): I would like to keep the buttons centered (with the gap in-between) regardless of the width of the superview (which will increase, for example, if the device is rotated to portrait orientation). Is there a way to define these autolayout constraints purely in the storyboard, or will I need to use NSLayoutConstraints in code? 回答1: You can achieve that by adding a constraint for each button to align the leading

Silence “Views without any layout constraints may clip their content” on a specific view controller that has preferredContentSize set

柔情痞子 提交于 2019-12-10 02:19:06
问题 I have a view controller that's fixed size (it can not be resized). This specific view controller is presented as a sheet in a window, I disabled the resizing by setting preferredContentSize . Since it can't be resized anymore, I left the view without any constraint. However, when I build the app, I got a lot of warnings that says : Views without any layout constraints may clip their content or overlap other views. I do know that if you don't add any constraints in a standard window it will

Auto-layout margins with anchors

别来无恙 提交于 2019-12-09 19:10:22
问题 So, I thought the following was equivalent? # This is how I usually do contentView.leftAnchor.constraint(equalTo: leftAnchor, constant: 5).isActive = true contentView.topAnchor.constraint(equalTo: topAnchor, constant: 5).isActive = true contentView.rightAnchor.constraint(equalTo: rightAnchor, constant: -5).isActive = true contentView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -5).isActive = true # This is what I tried. I expected the same result.. layoutMargins = UIEdgeInsets

add constraints programmatically swift

三世轮回 提交于 2019-12-09 14:38:25
问题 I am trying to add constraints to a facebook sdk login button. I have the button inside a scroll view and I am trying to add a top constraint to a label that is also in the scroll view. I am able to successfully add the height constraint with no run time errors but the actual constraint does not seem to be applied to the button. @IBOutlet weak var orLbl: UILabel! @IBOutlet weak var scrollView: UIScrollView! override func viewDidLoad() { super.viewDidLoad() var loginFBButton = FBSDKLoginButton

How to change Auto Layout constraints after they are set when using constraintEqualToAnchor()?

烈酒焚心 提交于 2019-12-09 08:02:24
问题 I try to set up a view with AutoLayout constraints by using constraintEqualToAnchor() : override func viewDidLoad() { super.viewDidLoad() let myView = UIView() myView.backgroundColor = UIColor.orangeColor() myView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(myView) myView.leftAnchor.constraintEqualToAnchor(view.leftAnchor).active = true myView.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor).active = true myView.topAnchor.constraintEqualToAnchor(view.topAnchor