LayoutKit
LayoutKit copied to clipboard
Action support
Now I can add a button as part of the layout and than regenerate the Layout in response to an user action. Could be useful to have a native support for states (Normal, Highlighted) in a way that the view could automatically update to reflect a given state. i.e. having a state parameter in the view config block
@lucabartoletti Do you have a use case where the actual layout (size, location) of the button changes depending on the state?
Usually these state changes only affect visual appearance, which means that you can set this up in the Layout's config
closure without needing to create a separate layout.
@nicksnyder Do you have any sample code for adding action support? Let's say I just want an image to be clickable, what is the optimal way to achieve that with LayoutKit?
@vladimirkofman You can add a gesture recognizer (or do anything else you might want to do with a UIView on the main thread) in the config block.
func tappableLayout(tapRecognizer: UITapGestureRecognizer) -> Layout {
return SizeLayout<UIView>(width: 50, height: 50, config: { (view) in
view.backgroundColor = UIColor.redColor()
view.addGestureRecognizer(tapRecognizer)
})
}
@nicksnyder Could you mind to add some action sample code in the example? It will help developer mush easier to understand Layoutkit.
@DesmondY there is no difference between LayoutKit and programmatically layouts when you want to add gesture recognizers.