Collections Fun @ the Queensland C# Mobile
Developers Meetup
Glenn Stephens
glenn@orchardebusiness.com
http://www.orcharde...
iOS ViewControllers
• Most of us are familiar with the common ones
• UINavigationController
• UITabViewController
Wednesda...
What if...
• We wanted a custom
display of sorts
• Its surprisingly simple
Wednesday, 31 July 13
To create custom collection systems
• You need to store a list of UIViewController
• Position these controllers where you ...
Creating custom collection systems
• For my Evernote style, I worked out the initial position based on the number
of tabs ...
Hitting the Green Tab
Hit the tab
Hit the controller
Wednesday, 31 July 13
Another example
• TabBar replacement
• Animates the tab status and buttons
• The same technique as the others
• Using Lazy...
Surprisingly simple
• Again, creating a new UIViewController subclass
• Storing a list of other UIViewController subclasse...
Declaring the class
! public class AnimatedTabBarViewController : UIViewController
! {
! ! public AnimatedTabBarViewContro...
Animating where required
! ! void ProcessTabButtonTouch (object sender, EventArgs e)
! ! {
! ! ! // Change the Tab
! ! ! A...
Q&A
• This was a quick 15 minute talk at the July 2013 Queensland C# Mobile
Developers Meetup
http://www.meetup.com/Queens...
Upcoming SlideShare
Loading in...5
×

Building Custom view controllers with Xamarin

2,232

Published on

Code is available at https://github.com/glennstephens/CustomCollections/
A fifteen minute talk at the last C# Mobile Developer meetup in Brisbane July 2013.

Takes you through the process of creating a custom styled collection container with Xamarin Studio

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,232
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Building Custom view controllers with Xamarin

  1. 1. Collections Fun @ the Queensland C# Mobile Developers Meetup Glenn Stephens glenn@orchardebusiness.com http://www.orchardebusiness.com 0432 933 972 Wednesday, 31 July 13
  2. 2. iOS ViewControllers • Most of us are familiar with the common ones • UINavigationController • UITabViewController Wednesday, 31 July 13
  3. 3. What if... • We wanted a custom display of sorts • Its surprisingly simple Wednesday, 31 July 13
  4. 4. To create custom collection systems • You need to store a list of UIViewController • Position these controllers where you want them • Animate between them (optional but recommended) • Perform Lazy Loading where/if possible Wednesday, 31 July 13
  5. 5. Creating custom collection systems • For my Evernote style, I worked out the initial position based on the number of tabs and then animated to and from the initial position • Tabs above the selected tab get animated up • Tabs below the selected tab get animated down • I expose two events OnShowTab and OnShowAll. I use this to do whatever I want in the area above the tabs, such as having a UIView fade in and out • Hitting the tab animates to the tab • Tapping the tab again goes back to the main screen Wednesday, 31 July 13
  6. 6. Hitting the Green Tab Hit the tab Hit the controller Wednesday, 31 July 13
  7. 7. Another example • TabBar replacement • Animates the tab status and buttons • The same technique as the others • Using Lazy loading of UIView Controllers this time Wednesday, 31 July 13
  8. 8. Surprisingly simple • Again, creating a new UIViewController subclass • Storing a list of other UIViewController subclasses • with some extra info this time • Using UIView based animation to get a smooth effect Wednesday, 31 July 13
  9. 9. Declaring the class ! public class AnimatedTabBarViewController : UIViewController ! { ! ! public AnimatedTabBarViewController () : base() ! ! { ! ! } ! ! public class TabEntry ! ! { ! ! ! public UIImage ButtonImage; ! ! ! public UIViewController ViewController; ! ! ! public UILabel Label = null; ! ! ! public TapableImageView Button = null; ! ! ! public bool HasCreated = false; ! ! ! public override string ToString () ! ! ! { ! ! ! ! return ViewController.Title; ! ! ! } ! ! } ! ! public List<TabEntry> Tabs = new List<TabEntry>(); ! ! public void AddTab(UIImage buttonImage, UIViewController viewController) Wednesday, 31 July 13
  10. 10. Animating where required ! ! void ProcessTabButtonTouch (object sender, EventArgs e) ! ! { ! ! ! // Change the Tab ! ! ! ActiveTabIndex = (sender as TapableImageView).Tag; ! ! ! ShowCurrentTab(); ! ! ! // Animate the Button Popping in and out ! ! ! UIView.BeginAnimations("MoveShapyThing"); ! ! ! UIView.SetAnimationDuration(0.4f); ! ! ! UIView.SetAnimationCurve(UIViewAnimationCurve.EaseInOut); ! ! ! _highlightShape.Frame = new RectangleF(PaddingSizeHorizontal + ActiveTabIndex * (RectangleWidth + PaddingSizeHorizontal), ! ! ! PaddingSizeVertical, RectangleWidth, RectangleHeight); ! ! ! UIView.CommitAnimations(); ! ! } Wednesday, 31 July 13
  11. 11. Q&A • This was a quick 15 minute talk at the July 2013 Queensland C# Mobile Developers Meetup http://www.meetup.com/Queensland-based-MonoTouch-and-Mono-for- Android/ • For more info, questions, or general Xamarin chit chat Email: glenn@orchardebusiness.com Web: http://www.orchardebusiness.com Skype: glennthomasstephens Wednesday, 31 July 13
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×