uistackview

Animating UIStackView arrangedSubview content size change

耗尽温柔 提交于 2019-12-05 03:23:40
Is it possible to animate an arranged subview when its intrinsic content size changes? For example, imagine I have an arranged subview, which holds a single UILabel pinned to edges. That label has a small amount of text. New text comes in, which is larger than the previous text. The intrinsic content size of label is now larger. I would like to be able to animate it like so: stackView.layoutIfNeeded() self.label.text = self.expanded ? textTwo : textOne UIView.animateWithDuration(0.3) { () -> Void in self.stackView.layoutIfNeeded() } The stackview currently "jumps" from the old content size to

Unresponsive UIButton in subview added to UIStackView

冷暖自知 提交于 2019-12-05 01:40:41
In the detailViewController of a UISplitView I have subviews added to a UIStackView inside a UIScrollView . Just using system buttons without subviews or images , results in responsive buttons, but subviews seem to interfere. Enabling touch is specifically coded. I have attempted to keep each view inside the containing view so there will be no overlap to invalidate receiving touch events, but not sure if this is done properly. Each subview contains a label and a custom button with an image. The subview is then added to the stackview , and the stackview to the scrollview . Thanks for any help.

How to size a UIStackView depending on its content?

半腔热情 提交于 2019-12-04 17:52:04
问题 I would like to have a similar behavior than the <Table> HTML tag, in the sense where the frame is sized according to its content. In my very context, I use an UIStackView as the content view of a UITableViewCell. As items in the cell are various information, the resulting height of the cell should be variable. My strategy is to programmatically build a cell as a UIStackView with a .Vertical axis, as in the code snippet as follows: override func tableView(tableView: UITableView,

Swift: Bring View from Stack View to front

谁说胖子不能爱 提交于 2019-12-04 15:28:11
I got a Stack View with view: 1,2,3,4 and 5 Looking for a method to bring the Image View4 from view4 in the Stack view, above all the other views. The reason I need this is because I am moving the Image View4 over the Image View3 in view3. I have tried to move view3 over view4 in the view hierarchy, but that just swaps their places in the Stack View. From the UIStackView documentation : The order of [the views in] the subviews array defines the Z-order of the subviews. If the views overlap, subviews with a lower index appear behind subviews with a higher index. So since all views in the stack

How To: Self-Sizing Custom-View from XIB with StackView View in iOS

巧了我就是萌 提交于 2019-12-04 08:56:25
问题 I've recently started diving into iOS development with Swift again and am now looking into a custom UIControl. For layout and flexibility this custom view is built using a StackView. What I want to achieve ... ... is basically to simply have the same functionality with the StackView that I usually have when I drag it directly into the storyboard - where it resizes to fit no problem. This essentially the same as self-sizing tableview cells. Showcase I can reduce my CustomView to a simple

How to center both vertical and horizontal inside a UIStackView

元气小坏坏 提交于 2019-12-04 07:13:59
I have a simple UIImageView with 50x50 size . If I had a UIView of size 100x100 and I wanted to center the image inside of it, all I have to do is set these But how do I do the same with a UIStackView of size 100x100 ? EDIT i think i should have been more clear. The questions is, how do i center the image both vertically & horizontally inside of the UIStackview ? Use two stack views. Vertical stack view with centre alignment. Inside that is a horizontal stack view with centre alignment t. Inside that is your image. You need to set the alignment to center inside attribute inspector of

Create Vertical lines between Uilabels inside of a stack view [duplicate]

对着背影说爱祢 提交于 2019-12-04 06:52:11
This question already has answers here : iOS - Add vertical line programatically inside a stack view (6 answers) Closed 2 years ago . I want to create a UICollectionView with a custom header in Code. Therefore i created a Subclass of UICollectionViewCell to describe my custom header. I want to display five labels in my header in a horizontal line. Therefore I created five labels and add them inside a stackView. The stackview show my labels filled equally. So far everything perfect. Label1 Label2 Label3 Label4 Label5 //Label 1 let votesLabel: UILabel = { let label = UILabel() let attributedText

UIStackView - drag to reorder arranged subviews?

一曲冷凌霜 提交于 2019-12-04 06:25:42
I'm trying to get some advice on how to go about implementing the same sort of "drag to reorder" behavior found on a UITableView but on a UIStackView . So far this is what I'm thinking: Add a long press gesture recognizer to each of the arrangedSubview s On long press, add an overlay UIView as a subview to the main view and that fills the entire main view. This overlay view will act as a "canvas" of sorts as I'm dragging the temporary "reorder" view—we'll call this the tempView — around (more on that in 4) Set the alpha of the arrangedSubview to 0 (setting hidden = true would result in the

Aligning multiple runtime generated UILabels in a UITableView

旧时模样 提交于 2019-12-04 06:25:24
问题 I have a UITableView that needs to support content by listing style something like But the tricky part is that the amount of "Label" will vary with each cell, some may have only 4 but also up to 12. Also the "Value" can be either a single word or short phrase up to two lines(like in the image above). So I decided to use UIStackView to help me pack and size my UILabels used to display this. I am currently stuck at a problem when the "Label" varies in length like: I need the leading end of the

how to use Stack View of object library in Xcode 7

☆樱花仙子☆ 提交于 2019-12-04 04:01:37
I recently installed Xcode 7 beta and found something new in object library like Horizontal stack view and Vertical stack view . When i put some controls inside it, stackview seems to be resizable according to the control size. When i present more controls the stack seems to be adjust automatically as of the stack view. Either adjusting horizontally or vertically? Is it derived from some other mobile platform A major advantage of using UIStackView is it uses Auto Layout to position and size its arranged UIViews . Therefore you dont need to worry about positioning UIViews in a UIStackView .For