autolayout

Swift - Make layout smaller for one device

寵の児 提交于 2019-12-25 09:34:07
问题 So I don't get the point to develop for 3,5 devices if the layout view is bigger than that, now some of the layouts doesn't fit in the 3.5 devices, what is the best way to solve it, I am already using Size Classes and Auto Layout. Is there any way to make things smaller just for the 3,5? 回答1: You can check @HAS answer for a great extension to get the device. You can simply add his extension to any file you want (outside of the class body). Then you check your device type like that: let model

UIView with Auto Layout doesn't increase height inside UIScrollView

强颜欢笑 提交于 2019-12-25 09:29:02
问题 What I'm trying to do is have a page similar to following wireframe that all UILabel s height should dynamically change based on the text: I currently have a UIView inside a UIScrollView . The issue is I can't get the UIView resize properly based on the its content, for example when description is long. The sample code can be downloaded from here If not into the mood for code, here's the constraints and how it's setup: I tried to use the approach mentioned in this post 回答1: FINALLY, found the

UITableViewController with different Cell sizes and Cell content in Storyboard

橙三吉。 提交于 2019-12-25 08:20:10
问题 I want to make a UITableViewController with different Cell sizes and different content of the cells. For example: Is there a way to use AutoLayout within the Storyboard to define the different sizes of the TableViewCells ? What would be the best way to define the content (a UIView with content on it) of the TableViewCells ? 回答1: To change the cells of the UITableView, you have 2 options: Option A (best) is to use Autosizing TableView Cells with Autolayout Constraints. To use option A, you

Align text fields using dynamic constraints

倾然丶 夕夏残阳落幕 提交于 2019-12-25 08:09:44
问题 I've been learning how to make iOS apps, and have come across a minor annoyance. I can't find an easy way to align my text inputs. Looking at the below screenshot, you will see that I've managed to align my text fields, which is what I want. However, I did this manually by changing the individual Leading Space between each Label and Text Field. My question is, how can I dynamically align my text fields? 回答1: Anand has posted nice way, but I personally use equal widths and heights in this kind

NSLayoutConsstraint constant not affecting view after UITapGestureRecognizer was tapped

偶尔善良 提交于 2019-12-25 07:41:06
问题 i have a view ( self.view ) that is masked with another view (not a layer) using the UIView.mask property. on self.view i installed a UIPanGestureRecognizer so when i pan across the screen the mask gets smaller and larger accordingly. in addition i installed on self.view a UITapGestureRecognizer which adds animatable UIImageView s to the screen and they are animating across a UIBezierPath . i am updating the mask size with constraints. the problem is that after i tap the screen to add

One label's constraints added using IB, one label's constraints added programmatically

我们两清 提交于 2019-12-25 07:34:52
问题 My goal is to position two labels on top of each other. I dragged a label onto the storyboard, labelA, and I pinned it a random distance from the top, and I centered labelA horizontally in the view, resulting in blue constraints. Then I dragged a second label, labelB, onto the storyboard and moved it below labelA (say, 1 inch separating the two labels). Now, I am trying to programmatically set the constraints for labelB to move it on top of labelA: import UIKit class ViewController:

Autolayout for Height working in iOS8 but not working in iOS7

百般思念 提交于 2019-12-25 06:59:00
问题 I have my UIImageView in the view which will download image from server and after downloading finish then my UIImageView height will be adjusted according to height of image but the problem is it is working perfectly in iOS8 but not in iOS7. In iOS7, the height is scaled to much more than I tried to set. I am setting autolayout via IB Here is the excerpt from my code (default is 250) if(image.size.height<250) headerView.itemImageView.contentMode = UIViewContentModeCenter; else{ adjustedHeight

I add a “align” constraint, but Xcode add a “pin” constraint autolayout

 ̄綄美尐妖づ 提交于 2019-12-25 04:45:29
问题 When we add constraints, we have the choice between "Align" button in the auto layout toolbar or "Pin" button. In my storyboard, if I add a new alignment constraint "Bottom edges" between a scrollview and his container. The icon of this constraint is 2 squares and a line. But after, in the list of constraints of my scrollview, the icon is different : The icon is a "Pin" icon. I don't understand why. One more question, I think it's related : what is the difference between "Align bottom" and

UILabel autoshrink and use 2 lines if necessary

徘徊边缘 提交于 2019-12-25 04:42:31
问题 I've got a UILabel that I would like to first shrink the text to fit a single line if possible. If that doesn't work I would like it to use at the most two lines. Is this possible? Currently with the settings I have it does this: Here is my layout If I change the lines setting to 1 line the text does shrink. 回答1: I came up with a solution. Set "Lines" to 2 Set "Line Breaks" to "Truncate Tail" Set "Autoshrink" to "Minimum Font Scale" and set the value to 0.1 (or however small you want it to be

Issue in designing layout for iPad & iPhone?

感情迁移 提交于 2019-12-25 04:33:57
问题 I have developed an app which should support both iPhone & iPad. I have designed screens using xocde 6 with autolayout. But the issue is, screens of my app looks good for iPhone but not for iPad. I have gone through This Link It says we should use size class for iPad & design our UI for iPad. So should i use separate size class for iPad? Doing this i will again have to design the UI for iPad. So is it the best way of designing screen using auotlayout? 回答1: If you don't want to use size class