autolayout

Autolayouts : How to create collapse/Expand dynamic view swift 3/4

隐身守侯 提交于 2020-08-20 19:07:17
问题 I have a problem that I can't create a view that can collapse it's contents that may be dynamic height , i know it's easy to collapse it with height constant = 0 , but i can't figure out how to make it expand again as the content of that view is dynamic and sub-itmes may be added later I want that behavior 回答1: Your answer has massively overcomplicated a very simple solution. You should first create your zeroHeightConstraint as a property. let zeroHeightConstraint: NSLayoutConstraint =

Autolayouts : How to create collapse/Expand dynamic view swift 3/4

一世执手 提交于 2020-08-20 19:00:17
问题 I have a problem that I can't create a view that can collapse it's contents that may be dynamic height , i know it's easy to collapse it with height constant = 0 , but i can't figure out how to make it expand again as the content of that view is dynamic and sub-itmes may be added later I want that behavior 回答1: Your answer has massively overcomplicated a very simple solution. You should first create your zeroHeightConstraint as a property. let zeroHeightConstraint: NSLayoutConstraint =

Xcode 8: Vary for traits changing layout for all size classes

血红的双手。 提交于 2020-07-18 05:27:46
问题 I am trying to use the very for traits feature on xcode 8.2.1 but when I change the layout of one size class using the 'vary for traits' and then 'done varying' when finished it is in fact changing the layout of every size class in my storyboard. e.g. I try to change the constraints on an ipad w: R, h: R by selecting vary for traits, turning the bar blue at the bottom. I make the necessary changes and click 'done varying' which changes the constraints. But then if I choose another device size

How to use constraint Identifiers in autolayout and how to change constrain using identifiers? [Swift]

允我心安 提交于 2020-07-08 11:09:28
问题 While I was editing my constraint in Xcode 7 I found identifier field in Interface Builder. What is an identifier for the constraint how do I use it? using identifier can I access constraint programmatically and change the constant? my question is why and how is that identifier is helpful? Is there any way to access the constraint with an identifier with looping in subviews and again looping constrain subviews. I mean is there any way we can access constraint directly without a loop. UPDATE I

iOS UILabel bounding rectangle not sized correctly

不问归期 提交于 2020-06-29 13:06:09
问题 I have a UILabel (as highlighted in yellow), which has the following conditions applied to it. Label has variable text length Font set to 40 Minimum font-size set to 20 Number of lines set to 3 Although this looks like a duplicated question I believe it is not. The issue I am having is that when the text exceeds the available 3 line length after being sized-down to 20 points, the UILabel's bounding box is sized incorrectly (i.e. note the extraneous spacing above and below the text). The end

Different Height for same UILabel Text

女生的网名这么多〃 提交于 2020-06-29 03:47:55
问题 I have two UILabel with (orange and pink one) one is multiline label and other one is just one label. Two of this component (which has same texts) is inside UIStackView and this Stackview is inside UITableView (Automatic dimension). My problem is that whether I set the same text to UILabels their heights look different. I'm searching for this problem for two days but none of solutions work for me. Ambiguous layout warnings for UILabels in UITableViewCell Label1 has top, left, right layout and

UICollectionViewCell not forcing Cell Size

久未见 提交于 2020-06-23 15:35:11
问题 I am using func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: 400, height: 600) } to specify my CollectionView 's cell sizes. It works fine but as soon as I add a width constraint (UILabel.width == ContentView.width) to my UILabel inside the ContentView of the cell, the cell's width shrinks to the intrinsic width of the UILabel . I am using