You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yesterday, I needed to add an activity spinner to one of my bulletin board pages, but I wanted it inline instead of a full page spinner. It is essentially: "Downloading Images" [spinner] [cancel button]
A standard UIView can't be easily added to the contentViews stack because it has no intrinsic content size. If you don't set a frame, it is sized to 0x0. If you do set a frame, it must be manually centered without access to the superview's frame. And you can't use constraints because it hasn't been added to the superview.
This custom UIView (thanks StackOverflow!) solves the problem by forcing an intrinsic size.
// NOTE: only height is honored by the current StackView settings
class IntrinsicSizeView: UIView {
var width: CGFloat = 32.0
var height: CGFloat = 32.0
convenience init(width: CGFloat, height: CGFloat) {
self.init()
self.width = width
self.height = height
}
override var intrinsicContentSize: CGSize {
get {
return CGSize(width: width, height: height)
}
}
}
Now as it turns out, UIActivityIndicatorView does have an intrinsic size, and this wasn't necessary for my particular case. But it may help someone else, and I thought it might be a nice addition to BulletinInterfaceBuilder, e.g. makeFixedSizeView(width, height) could vend a BulletinBoardFixedHeightView or something along those lines.
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion! I've implemented this in 933402c. There is now a view named BLTNContainerView that allows you to specify a content size. You can set the child view (such as an activity indicator or a collection view), and set up its constraints with Auto Layout inside a block.
As you suggested, I added a utility method on BLTNInterfaceBuilder to make integration easier. For example, if you had an activity indicator, you could add it to the stack this way:
This feature shipped with the version 2.0.0-beta.3 of the library. Thanks again for your suggestion. Do not hesitate to reopen the issue if you have any feedback.
Yesterday, I needed to add an activity spinner to one of my bulletin board pages, but I wanted it inline instead of a full page spinner. It is essentially: "Downloading Images" [spinner] [cancel button]
A standard UIView can't be easily added to the contentViews stack because it has no intrinsic content size. If you don't set a frame, it is sized to 0x0. If you do set a frame, it must be manually centered without access to the superview's frame. And you can't use constraints because it hasn't been added to the superview.
This custom UIView (thanks StackOverflow!) solves the problem by forcing an intrinsic size.
Now as it turns out, UIActivityIndicatorView does have an intrinsic size, and this wasn't necessary for my particular case. But it may help someone else, and I thought it might be a nice addition to BulletinInterfaceBuilder, e.g. makeFixedSizeView(width, height) could vend a BulletinBoardFixedHeightView or something along those lines.
The text was updated successfully, but these errors were encountered: