Class: SwipeTitleController
- Inherits:
-
UIViewController
- Object
- UIViewController
- SwipeTitleController
- Defined in:
- lib/swipe_title/swipe_title_controller.rb
Constant Summary collapse
- CELL_ID =
'CellID'
Instance Attribute Summary collapse
-
#delegate ⇒ Object
Returns the value of attribute delegate.
-
#selectedIndex ⇒ Object
Returns the value of attribute selectedIndex.
Instance Method Summary collapse
- #scrollToItemAtIndex(index) ⇒ Object
-
#swipeBegan ⇒ Object
Called by Swipe Collection View Controller.
- #swipeEnded ⇒ Object
- #swipeTitleControllerSelectedIndex(controller, index) ⇒ Object
- #titles=(titles) ⇒ Object
- #viewDidLoad ⇒ Object
- #viewWillLayoutSubviews ⇒ Object
Instance Attribute Details
#delegate ⇒ Object
Returns the value of attribute delegate.
5 6 7 |
# File 'lib/swipe_title/swipe_title_controller.rb', line 5 def delegate @delegate end |
#selectedIndex ⇒ Object
Returns the value of attribute selectedIndex.
6 7 8 |
# File 'lib/swipe_title/swipe_title_controller.rb', line 6 def selectedIndex @selectedIndex end |
Instance Method Details
#scrollToItemAtIndex(index) ⇒ Object
33 34 35 36 |
# File 'lib/swipe_title/swipe_title_controller.rb', line 33 def scrollToItemAtIndex index @swipeController.scrollToItemAtIndex index @pageControl.currentPage = index end |
#swipeBegan ⇒ Object
Called by Swipe Collection View Controller
54 55 56 |
# File 'lib/swipe_title/swipe_title_controller.rb', line 54 def swipeBegan view.layer.shadowOpacity = 1 end |
#swipeEnded ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/swipe_title/swipe_title_controller.rb', line 58 def swipeEnded UIView.transitionWithView view, duration: 0.1, options: UIViewAnimationOptionTransitionCrossDissolve, animations: -> { view.layer.shadowOpacity = 0 }, completion:nil end |
#swipeTitleControllerSelectedIndex(controller, index) ⇒ Object
38 39 40 41 |
# File 'lib/swipe_title/swipe_title_controller.rb', line 38 def swipeTitleControllerSelectedIndex controller, index @pageControl.currentPage = index delegate.swipeTitleControllerSelectedIndex controller, index end |
#titles=(titles) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/swipe_title/swipe_title_controller.rb', line 43 def titles= titles @pageControl.numberOfPages = titles.length @pageControl.hidden = titles.length == 1 @swipeController.titles = titles @swipeController.reloadData end |
#viewDidLoad ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/swipe_title/swipe_title_controller.rb', line 8 def viewDidLoad view.layer.tap do |l| l.masksToBounds = false l.cornerRadius = 5 l.shadowOffset = CGSizeMake(0, 0) l.shadowRadius = 8 l.shadowOpacity = 0 end @swipeController = SwipeCollectionViewController.alloc.initWithFrame(CGRectZero) @swipeController.delegate = self view.addSubview @swipeController.collectionView @pageControl = UIPageControl.alloc.initWithFrame(CGRectZero) @pageControl.userInteractionEnabled = false view.addSubview @pageControl end |
#viewWillLayoutSubviews ⇒ Object
26 27 28 29 30 31 |
# File 'lib/swipe_title/swipe_title_controller.rb', line 26 def viewWillLayoutSubviews @swipeController.collectionView.frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height) @pageControl.frame = CGRectMake(0, view.frame.size.height - 14, view.frame.size.width, 14) end |