Class: Tgios::AnimatableView
- Inherits:
-
UIView
- Object
- UIView
- Tgios::AnimatableView
- Defined in:
- lib/tgios/animatable_view.rb
Constant Summary collapse
- DURATION =
0.25
Instance Method Summary collapse
Instance Method Details
#hide_animated ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tgios/animatable_view.rb', line 35 def hide_animated if @is_shown @hide_notification ||= NSNotification.notificationWithName( UIKeyboardWillHideNotification, object: self, userInfo:{UIKeyboardAnimationCurveUserInfoKey=> UIViewAnimationOptionCurveEaseInOut, UIKeyboardAnimationDurationUserInfoKey=> DURATION}) UIView.animateWithDuration(DURATION, animations: ->{ NSNotificationCenter.defaultCenter.postNotification(@hide_notification) self.alpha = 0.0 frame = self.frame frame.origin.y = self.superview.frame.size.height self.frame = frame }) @is_shown = false end end |
#initWithFrame(frame) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/tgios/animatable_view.rb', line 5 def initWithFrame(frame) super bg_view = PlasticCup::Base.style(UIView.new, frame: self.bounds, backgroundColor: :white.uicolor, alpha: 0.95) self.addSubview(bg_view) if self.layer.respondsToSelector('setAllowsGroupOpacity:') self.layer.allowsGroupOpacity = false end self end |
#is_shown ⇒ Object
53 54 55 |
# File 'lib/tgios/animatable_view.rb', line 53 def is_shown @is_shown end |
#show_animated ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tgios/animatable_view.rb', line 18 def show_animated new_frame = self.frame new_frame.origin.y = self.superview.frame.size.height - self.bounds.size.height @show_notification ||= NSNotification.notificationWithName( UIKeyboardWillShowNotification, object: self, userInfo:{UIKeyboardFrameEndUserInfoKey=> NSValue.valueWithCGRect(self.superview.convertRect(new_frame, toView: nil)), UIKeyboardAnimationCurveUserInfoKey=> UIViewAnimationOptionCurveEaseInOut, UIKeyboardAnimationDurationUserInfoKey=> DURATION}) UIView.animateWithDuration(DURATION, animations: ->{ NSNotificationCenter.defaultCenter.postNotification(@show_notification) self.alpha = 1.0 self.frame = new_frame }) @is_shown = true end |