autolayout

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

Constraints to center and object between two objects

对着背影说爱祢 提交于 2019-12-21 07:46:03
问题 My design requires that a button is centered between two other objects. One of the objects is in the vertical center of the view (green). The other object is some distance from the bottom edge (green). Now the task is to center the third object (red) between the other two. I am using xcode6's new constraints and my view is in wRegular hRegular mode. This would be easy with code, but I am trying to use the storyboard to accomplish this. 回答1: There are a number of approaches: In iOS 9, the

Constraints to center and object between two objects

心不动则不痛 提交于 2019-12-21 07:45:47
问题 My design requires that a button is centered between two other objects. One of the objects is in the vertical center of the view (green). The other object is some distance from the bottom edge (green). Now the task is to center the third object (red) between the other two. I am using xcode6's new constraints and my view is in wRegular hRegular mode. This would be easy with code, but I am trying to use the storyboard to accomplish this. 回答1: There are a number of approaches: In iOS 9, the

Constraints to center and object between two objects

青春壹個敷衍的年華 提交于 2019-12-21 07:44:08
问题 My design requires that a button is centered between two other objects. One of the objects is in the vertical center of the view (green). The other object is some distance from the bottom edge (green). Now the task is to center the third object (red) between the other two. I am using xcode6's new constraints and my view is in wRegular hRegular mode. This would be easy with code, but I am trying to use the storyboard to accomplish this. 回答1: There are a number of approaches: In iOS 9, the

Variable width & height of UICollectionViewCell using AutoLayout with Storyboard (without XIB)

本秂侑毒 提交于 2019-12-21 07:31:42
问题 Here is an design issue in the app that uses AutoLayout, UICollectionView and UICollectionViewCell that has automatically resizable width & height depending on AutoLayout constraints and its content (some text). It is a UITableView list like, with each cell that has it's own width & height calculated separately for each row dependant on its content. It is more like iOS Messages build in app (or WhatsUp). It is obvious that app should make use of func collectionView(collectionView:

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

How to position activity indicator to the center of its superview using Auto Layout programmatically?

做~自己de王妃 提交于 2019-12-21 07:12:27
问题 Why the following code does not work for positioning activity indicator to the center of its superview: UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; [self.mysuperview addSubview:activityIndicator]; [activityIndicator addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-(>=20)-[view(==100)]-(>=20)-|" options:NSLayoutFormatAlignAllCenterX | NSLayoutFormatAlignAllCenterY metrics

Autolayout is not resizing Uicollectionviewcell items when animating between layouts

旧巷老猫 提交于 2019-12-21 06:36:31
问题 I have a uicollectionview cell with an image view inside that I want to resize when I switch to a larger 'zoomed in' layout. I have placed constraints inside the cell that does resize the image view when the zoomed in layout is displayed. I am using uicollectionview setLayout animated method. The problem is the image does not scale with animation only the collection view cell does. The image seems to just jump into its end size with no interpolation. So the animation looks extremely choppy.

How to handle iPhone 4s, 5 and 6 screen size, and make all the contents look the same across al the devices

好久不见. 提交于 2019-12-21 05:47:06
问题 I am using Xcode 6.1 and in one of the views I have, contains many labels. However, these labels look different in each different devices. Although I have add constraints to all the labels, but still facing the same issue. How can I get the same view layout across all devices? How can I make the width and height for each label is flexible, depends on the screen size? Do I need to design different xib for each device? The following images showing the result am getting, with auto resize enabled