autolayout

move button towards target using constraints, no reaction?

无人久伴 提交于 2020-01-07 05:53:06
问题 I would like the red button to be animated towards the leading position of the second button : Some examples showed how to change the "constant" with numbers, but I would like to put automatically at the leading position of the second button. I tried this, but the red button does not move, the animations log is correctly called though : - (void)updateConstr{ NSLayoutConstraint *newLeading = [NSLayoutConstraint constraintWithItem:self.redB attribute:NSLayoutAttributeLeading relatedBy

How to make UILabel and UITextField font size to be relative to screen size

喜夏-厌秋 提交于 2020-01-07 05:43:05
问题 I have a view controller which has a text field and label and I have set height constraint for text field and label and so I feel font size is not relative to the screen I believe. How can I make this items' font size to be relative to the screen size? 回答1: You can manually change UIlabel or UITextfield font in viewDidLayoutSubviews method of your ViewController or layoutSubviews method of your superView . Like this: CGRect screenSize = [UIScreen mainScreen].bounds; textField.font = [UIFont

How to make UILabel and UITextField font size to be relative to screen size

本秂侑毒 提交于 2020-01-07 05:42:12
问题 I have a view controller which has a text field and label and I have set height constraint for text field and label and so I feel font size is not relative to the screen I believe. How can I make this items' font size to be relative to the screen size? 回答1: You can manually change UIlabel or UITextfield font in viewDidLayoutSubviews method of your ViewController or layoutSubviews method of your superView . Like this: CGRect screenSize = [UIScreen mainScreen].bounds; textField.font = [UIFont

iOS Auto Layout flexible margins

核能气质少年 提交于 2020-01-07 03:47:29
问题 I'm trying to create a layout that contains flexible vertical margins between specific elements of the static height in Interface Builder . Since I have no idea how I can define that, I tried using "spacer" views with flexible height. The layout I created in Interface Builder is the following: The blue rectangles are the static height ones, and their height should not change . But their margins and spacing between them should change based on screen size. The red rectangles are the spacing

Centering two side-by-side objects

∥☆過路亽.° 提交于 2020-01-07 03:05:23
问题 I'm trying to follow the solution described here: XCode 7 Autolayout Constraints: How to make 2 images stay horizontally in the center But it is not working for me. These are the screenshots from the Attribute Inspector for the constraints that I ended up with: Can anyone see where I am going wrong? Thanks! 回答1: You turned the constraints around - the leading/trailing of the image views have to be connected to the center of the superview to achieve what you want to do. 回答2: Whatever I do, I

How To shift a view with animation with auto layout constraints are on iOS

折月煮酒 提交于 2020-01-06 19:36:36
问题 I am doing a task in which, i need to shift the view by 35 pixels in order to show a view which is present below that view. Or you can say i need to insert a bar like notification on top and shift the existing view by 35 pixels at runtime. The problem is with auto layout on in order to support all the screens. Shifting is not happening as we want.... Any suggestions here ? Top view has a constraint that its distance with top view is zero, which needs to change at runtime, when we to show the

Interface Builder: automatically set aspect ratio for UIImageView when using “Aspect Fit”?

六月ゝ 毕业季﹏ 提交于 2020-01-06 07:58:45
问题 The share icon (image is white) below is 114x128 pixels. Fixing the height in Interface Builder to 23 pixels with AutoLayout then using Aspect Fit for the Content Mode does not change the frame rectangle, though. This causes issues with alignment since if you want the icon 15 pixels from the trailing edge, it's now hard to do so. One option is to manually set the aspect ratio (i.e., 114/128) as an AutoLayout constraint within IB. But this is extremely fragile. If you change the image

On rotation cell height gets lost on iOS 8 when using auto layout

荒凉一梦 提交于 2020-01-06 07:14:53
问题 Normally iOS 8 should be able to calculate the height of a cell itself. This is working so far, but if I rotate the device the cell gets back to its standard height of 44 points. This is how it should look like: This is how it does look like after rotation: Once rotated it stays in that layout. It never calculates the real height anymore. I don't know why. I have added my complete code. For the constraints have a look into updateConstraints . The code is in C# but you should be able to read

Image grows even if content/compression is set to 1

安稳与你 提交于 2020-01-06 07:04:38
问题 This is what I want to create programmatically: So that is a UIView, and inside it there is a UIImageView and a UILabel. Some notes: The image should always be 1:1 The image's height should be the same as the height of the label If the text in the label gets wider, the view should go wider as well. The view's height should adapt to the label's height, so I did not have set any height constraint of the UIView. See this github project for an example what I want: https://github.com/Jasperav

Image grows even if content/compression is set to 1

ⅰ亾dé卋堺 提交于 2020-01-06 07:04:09
问题 This is what I want to create programmatically: So that is a UIView, and inside it there is a UIImageView and a UILabel. Some notes: The image should always be 1:1 The image's height should be the same as the height of the label If the text in the label gets wider, the view should go wider as well. The view's height should adapt to the label's height, so I did not have set any height constraint of the UIView. See this github project for an example what I want: https://github.com/Jasperav