nslayoutconstraint

Understanding Constraints using Xcode and Manually Coding

假如想象 提交于 2019-12-23 04:26:27
问题 I just read few information about how to manipulates constraints number programatically, but I think I need to see it visually using Xcode. So I decided to put a UIView like this and see what's going on with Constraints : automatically it will create 4 constraints : after modifying the number, I got what's the meaning of all this. there we have 2 vertical space and 2 horizontal space. but let's focus on vertical first... one of vertical space measured from top of the screen (superview, I

Updating existing constraints does not work, wrong use of .active property?

风流意气都作罢 提交于 2019-12-22 18:48:21
问题 I have a storyboard that contains : A "tab bar" on the left with 5 tabs A container on the right side of the tab bar that contains 6 image views that share the same space so it looks like this : Each image view is configured to occupy 1/3 of the container's width and 1/2 of its height. However, different ratios can be provided at runtime (from a JSON file) so that for example, the 1st image view's height become 70% of its container's height and 50% of its width (therefore, the 2nd and 3rd

How to handle NSLayoutConstraints with screen size/orientation changes in iOS 8/Swift?

妖精的绣舞 提交于 2019-12-22 13:05:40
问题 How to work with IB Constraints and NSLayoutConstraint ? I want to programmatically fine-tune my Interface Builder Storyboard layout, as I can't achieve desired layout with constraints in Interface Builder alone. The iPhone 4S and iPhone 6 Plus are particularly challenging for my iOS 8 layouts. Questions: How do I find screen dimensions when the UIViewController appears? How do I detect orientation changes & resulting screen dimensions in iOS 8? How do I modify layout constraints

How to handle NSLayoutConstraints with screen size/orientation changes in iOS 8/Swift?

三世轮回 提交于 2019-12-22 13:04:46
问题 How to work with IB Constraints and NSLayoutConstraint ? I want to programmatically fine-tune my Interface Builder Storyboard layout, as I can't achieve desired layout with constraints in Interface Builder alone. The iPhone 4S and iPhone 6 Plus are particularly challenging for my iOS 8 layouts. Questions: How do I find screen dimensions when the UIViewController appears? How do I detect orientation changes & resulting screen dimensions in iOS 8? How do I modify layout constraints

Is it possible to pin a UIView's top to the bottom of the navigation bar?

和自甴很熟 提交于 2019-12-22 10:54:22
问题 I'm trying to position my UIView to be 20pt under the navigation bar, but when I set it relative to the view on the view controller it's still under the navigation bar at 20pt, and I don't want to hardcode it. Is it possible to position it away from the navigation bar? 回答1: Try adding contraint with TopLayoutGuide, The main difference between TopLayoutGuide and self.view is, top layout guide starts with bottom of status bar + bottom of navigation bar(if exist) , but self.view always start

Combining NSLayoutConstraints with CALayer backed views does not animate correctly

自作多情 提交于 2019-12-22 08:51:35
问题 I have an auto layout setup with an animation that alters a NSLayoutContraint constant value // set the slide in view's initial height to zero self.adViewHeightConstraint = [NSLayoutConstraint constraintWithItem:self.adContainerView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:0.0]; [self.view addConstraint:self.adViewHeightConstraint]; // later, set the slid in view's height to non-zero double

Animating Constraint Changes, position animates but height jumps without animation

情到浓时终转凉″ 提交于 2019-12-22 06:55:44
问题 I have a custom UIView. Within that UIView I have a UILabel with a yellow background containing @"8" called labelWhite . I programmatically create 4 constraints for that UILabel: top, left, width, and height. When I tap the UIView, I change the constant value of the height and animate the layout over 5 seconds. However, the height of the view immediately jumps to the new value, but the y position also changes and jumps to a new value immediately. Then over the 5 second animation, the y

How to fix strange NSLayoutConstraint errors that don't seem to effect layout in custom UITableViewCell

醉酒当歌 提交于 2019-12-22 06:35:13
问题 Each time one of my custom UITableViewCells is drawn by tableView:cellForRowAtIndexPath: The console spits out a bunch of NSLayoutConstraint inconsistencies. I understand most of these: Unable to simultaneously satisfy constraints. ...boring stuff.. "<NSLayoutConstraint:0x8b0eb60 V:|-(NSSpace(20))-[UILabel:0x8b0cb30] (Names: '|':UITableViewCellContentView:0x8bd7d40 )>", "<NSLayoutConstraint:0x8b0db70 V:[UILabel:0x8b0cb30]-(NSSpace(8))-[UITextView:0x91dba00]>", "<NSLayoutConstraint:0x8b0dba0 V

Xcode auto layout constraints - why defaulting to negative padding?

不想你离开。 提交于 2019-12-21 09:08:32
问题 I am simply adding a UIView into the main view of a view controller. I want the height to always be 64px, but the width to stretch to the width of the screen. However, when I go to add constraints, the left and right padding default to -16, even though the view is stretched all the way across its parent view. Even if I set these back to 0, when I run the app the -16 padding is added back in. What is going on here? 回答1: Uncheck "Constrain to margins" checkbox in the pin menu (the first image

Xcode auto layout constraints - why defaulting to negative padding?

非 Y 不嫁゛ 提交于 2019-12-21 09:08:11
问题 I am simply adding a UIView into the main view of a view controller. I want the height to always be 64px, but the width to stretch to the width of the screen. However, when I go to add constraints, the left and right padding default to -16, even though the view is stretched all the way across its parent view. Even if I set these back to 0, when I run the app the -16 padding is added back in. What is going on here? 回答1: Uncheck "Constrain to margins" checkbox in the pin menu (the first image