uistackview

Programmatically add subviews to a UIStackView

▼魔方 西西 提交于 2019-12-21 09:35:13
问题 I'm trying to implement a table view cell that displays a series of icons that represent home amenities (e.g. towels, wifi, laundry, etc.). The cell could potentially display a large number of amenities (depending on how many the home has), so I'll display a maximum of three and indicate that you can view more by clicking on the cell if there are more than three. Here is what it should look like (from Airbnb's app): I am trying to do this by dynamically adding UIImageViews to a UIStackView in

Constraints to center and object between two objects

对着背影说爱祢 提交于 2019-12-21 07:46:03
问题 My design requires that a button is centered between two other objects. One of the objects is in the vertical center of the view (green). The other object is some distance from the bottom edge (green). Now the task is to center the third object (red) between the other two. I am using xcode6's new constraints and my view is in wRegular hRegular mode. This would be easy with code, but I am trying to use the storyboard to accomplish this. 回答1: There are a number of approaches: In iOS 9, the

Constraints to center and object between two objects

心不动则不痛 提交于 2019-12-21 07:45:47
问题 My design requires that a button is centered between two other objects. One of the objects is in the vertical center of the view (green). The other object is some distance from the bottom edge (green). Now the task is to center the third object (red) between the other two. I am using xcode6's new constraints and my view is in wRegular hRegular mode. This would be easy with code, but I am trying to use the storyboard to accomplish this. 回答1: There are a number of approaches: In iOS 9, the

Constraints to center and object between two objects

青春壹個敷衍的年華 提交于 2019-12-21 07:44:08
问题 My design requires that a button is centered between two other objects. One of the objects is in the vertical center of the view (green). The other object is some distance from the bottom edge (green). Now the task is to center the third object (red) between the other two. I am using xcode6's new constraints and my view is in wRegular hRegular mode. This would be easy with code, but I am trying to use the storyboard to accomplish this. 回答1: There are a number of approaches: In iOS 9, the

Nested UIStackViews Broken Constraints

人盡茶涼 提交于 2019-12-20 09:30:57
问题 I have a complex view hierarchy, built in Interface Builder, with nested UIStackViews. I get "unsatisfiable constraints" notices every time I hide some of my inner stackviews. I've tracked it down to this: ( "<NSLayoutConstraint:0x1396632d0 'UISV-canvas-connection' UIStackView:0x1392c5020.top == UILabel:0x13960cd30'Also available on iBooks'.top>", "<NSLayoutConstraint:0x139663470 'UISV-canvas-connection' V:[UIButton:0x139554f80]-(0)-| (Names: '|':UIStackView:0x1392c5020 )>", "

Swift: Disappearing views from a stackView

≡放荡痞女 提交于 2019-12-18 15:04:55
问题 I have a fairly simple set up in my main storyboard: A stack view which includes three views The first view has a fixed height and contains a segment controller The other two views have no restrictions, the idea being that only one will be active at a time and thus fill the space available I have code that will deal with the changing view active views as follows: import Foundation import UIKit class ViewController : UIViewController { @IBOutlet weak var stackView: UIStackView! @IBOutlet weak

Negative spacer for UIBarButtonItem in navigation bar on iOS 11

折月煮酒 提交于 2019-12-17 15:37:47
问题 In iOS 10 and below, there was a way to add a negative spacer to the buttons array in the navigation bar, like so: UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; negativeSpacer.width = -8; self.navigationItem.leftBarButtonItems = @[negativeSpacer, [self backButtonItem]]; This no longer works on iOS 11 (the spacer becomes positive, instead of negative). I have inspected the view hierarchy of the bar

How to set weight in UIStackView in IOS

泄露秘密 提交于 2019-12-13 13:00:17
问题 UIStackView is similar to Android LinearLayout but I could not figure out how to set weight for the subviews. Suppose I have a vertical UIStackView and 3 UIImageView s in it. I want to set weights 3, 6, 1 consecutively for the UIImageView s. How do I do that? 回答1: UIStackView doesn't have the same concept of weights. It can use a subview's intrinsicContentSize as a weight, but setting a specific intrinsicContentSize typically requires making a subclass and it's used in other situations too

Problems of constraints: sizeToFit doesn't work

折月煮酒 提交于 2019-12-13 05:36:10
问题 I'm very new to iOS developement, I'm starting to use auto layout and constraint. I come from Web design so some behaviour are very confusing to me. I'm trying to do a vertical menu taking all the page (centered X and Y). I have made a custom class just for this menu. The goal is to create any menu easily when I need it just like that: myMenu = MyMenu([ MyMenu.ButtonInfo("Galerie","icon_gallery",onclick:{return}), MyMenu.ButtonInfo("Camera","icon_camera",onclick:{return}) ]); myMenu.show()

UIStackView Hiding/UnHiding arrangedSubView issue

可紊 提交于 2019-12-12 18:42:05
问题 I am hiding and unhiding dropDownView(UIView consisting of textfield and button) based on Segment tapped in Segment Control. Following is the view hierarchy :- Following is the code which hides/unhides dropDownView :- private func animateView(view: UIStackView, toHidden hidden: Bool) { UIView.animate(withDuration: 0.25) { let firstView = view.arrangedSubviews[0] firstView.isHidden = hidden } } func segmentValueChanged(_ sender: UISegmentedControl) { let segmentSelected = segmentControl