ios-autolayout

How to keep a round imageView round using auto layout?

£可爱£侵袭症+ 提交于 2019-11-27 07:33:19
How do I turn a rectangular image view into a circular image view that can hold shape in auto layout without setting width and height restraints? Thereby allowing the imageView to define it’s size, and size bigger and smaller relative to objects around it with leading, trailing, top, and bottom constraints. I asked a similar question the other day, but I think this might be posed in a more concise way. Thanks so much! EDIT Ok, I started over to make this as simple as possible. I have a view named "Cell" and a UIImageView named "dog" within the cell, and that's it. I don't have "unable to

How do I set collection view's cell size via the auto layout

折月煮酒 提交于 2019-11-26 22:50:54
问题 Hi I'm trying to resize the cell via the auto layout . I want display the cell by the 3 by 3. First Cell's margin left=0 Last Cell's margin right=0 And all of the cell's space has 1pt. Like an instagram . Should I set to Cell's Size? I want set constraint via the Autolayout. I also trying to set cell's size using the code. Here is my code: func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -

What is 'Vary for Traits' in Xcode 8?

人走茶凉 提交于 2019-11-26 21:15:15
I am using AutoLayout and Size classes, but with release of iOS 10 and new Xcode 8.0, there is one new option Vary for Traits . Is this replacement of Size Classe for different width and height of devices. By selection of width checkbox, it displays varying 14 compact width devices . By selection of height checkbox, it displays varying 18 compact height devices . By selection of both checkbox, it displays varying 11 compact width regular height devices . How to make use of this options ? Can we use AutoLayout with size classes as like Xcode7.0 ? If any one has in depth knowledge then please

How to update the constant height constraint of a UIView programmatically?

有些话、适合烂在心里 提交于 2019-11-26 19:48:26
I have a UIView and I set the constraints using Xcode Interface Builder. Now I need to update that UIView's height constant programmatically. There is a function that goes like myUIView.updateConstraints() , but I don't know how to use it. Select the height constraint from the Interface builder and take an outlet of it. So, when you want to change the height of the view you can use the below code. yourHeightConstraintOutlet.constant = someValue yourView.layoutIfNeeded() Method updateConstraints() is an instance method of UIView . It is helpful when you are setting the constraints

How to keep a round imageView round using auto layout?

一世执手 提交于 2019-11-26 17:40:34
问题 How do I turn a rectangular image view into a circular image view that can hold shape in auto layout without setting width and height restraints? Thereby allowing the imageView to define it’s size, and size bigger and smaller relative to objects around it with leading, trailing, top, and bottom constraints. I asked a similar question the other day, but I think this might be posed in a more concise way. Thanks so much! EDIT Ok, I started over to make this as simple as possible. I have a view

How to keep a round imageView round using auto layout?

不羁的心 提交于 2019-11-26 13:45:04
问题 How do I turn a rectangular image view into a circular image view that can hold shape in auto layout without setting width and height restraints? Thereby allowing the imageView to define it’s size, and size bigger and smaller relative to objects around it with leading, trailing, top, and bottom constraints. I asked a similar question the other day, but I think this might be posed in a more concise way. Thanks so much! EDIT Ok, I started over to make this as simple as possible. I have a view

In iOS 12, when does the UICollectionView layout cells, use autolayout in nib

蹲街弑〆低调 提交于 2019-11-26 09:16:48
问题 Same code like this collectionLayout.estimatedItemSize = CGSize(width: 50, height: 25) collectionLayout.itemSize = UICollectionViewFlowLayoutAutomaticSize collectionLayout.minimumInteritemSpacing = 10 for _ in 0 ..< 1000 { let length = Int(arc4random() % 8) let string = randomKeyByBitLength(length) array.append(string!) } collectionView.reloadData() cell constraints: when I run it on iOS 12, it\'s different. left simulator is iOS 11, and right is iOS 12: But, when I scroll it, cells\'s frames

How to update the constant height constraint of a UIView programmatically?

橙三吉。 提交于 2019-11-26 07:26:12
问题 I have a UIView and I set the constraints using Xcode Interface Builder. Now I need to update that UIView\'s height constant programmatically. There is a function that goes like myUIView.updateConstraints() , but I don\'t know how to use it. 回答1: Select the height constraint from the Interface builder and take an outlet of it. So, when you want to change the height of the view you can use the below code. yourHeightConstraintOutlet.constant = someValue yourView.layoutIfNeeded() Method

What is NSLayoutConstraint “UIView-Encapsulated-Layout-Height” and how should I go about forcing it to recalculate cleanly?

牧云@^-^@ 提交于 2019-11-26 05:53:29
I have a UITableView running under iOS 8 and I'm using automatic cell heights from constraints in a storyboard. One of my cells contains a single UITextView and I need it to contract and expand based on user input - tap to shrink/expand the text. I'm doing this by adding a runtime constraint to the text view and changing the constant on the constraint in response to user events: -(void)collapse:(BOOL)collapse; { _collapsed = collapse; if(collapse) [_collapsedtextHeightConstraint setConstant: kCollapsedHeight]; // 70.0 else [_collapsedtextHeightConstraint setConstant: [self

What is NSLayoutConstraint “UIView-Encapsulated-Layout-Height” and how should I go about forcing it to recalculate cleanly?

旧时模样 提交于 2019-11-26 03:25:59
问题 I have a UITableView running under iOS 8 and I\'m using automatic cell heights from constraints in a storyboard. One of my cells contains a single UITextView and I need it to contract and expand based on user input - tap to shrink/expand the text. I\'m doing this by adding a runtime constraint to the text view and changing the constant on the constraint in response to user events: -(void)collapse:(BOOL)collapse; { _collapsed = collapse; if(collapse) [_collapsedtextHeightConstraint setConstant