-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
I'm trying to animate constraint changes when the user taps on a segmented control. I'm using style_classes to achieve this, but it doesn't seem to be working. I checked and, at runtime, the style_classes of the two views are changing, but nothing is happening on screen. I thought maybe it would be an immediate change, but I'm not even getting that.
Here's the code I'm using:
# from app/styles/stylesheet.rb
Teacup::Stylesheet.new :main do
PADDING = 20
style :onscreen,
constraints: [
:center_x,
constrain(:width).equals(:superview, :width).minus(2 * PADDING),
constrain(:bottom).equals(:segmented_control, :top).minus(PADDING),
constrain(:top).equals(:superview, :top).plus(PADDING),
]
style :offscreen_right,
constraints: [
constrain(:right).equals(:superview, :right).plus(500),
]
style :offscreen_left,
constraints: [
constrain(:left).equals(:superview, :left).plus(500),
]
end# from app/controllers/view_controller.rb
segmented_control.on :value_changed do |sender|
a_styles, b_styles =
if sender.selectedSegmentIndex == 0
[[:onscreen], [:offscreen_right]]
else
[[:offscreen_left], [:onscreen]]
end
UIView.animateWithDuration(0.3, animations:->{
a_view.style_classes = a_styles
b_view.style_classes = b_styles
})
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels