Created
January 14, 2013 16:41
-
-
Save Splat/4531390 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using MonoTouch.UIKit; | |
using MonoTouch.Foundation; | |
using MonoTouch.CoreGraphics; | |
public class SplatClearToolbar: UIToolbar | |
{ | |
UIViewController vc; | |
public SplatClearToolbar (UIViewController vc) : base () | |
{ | |
this.vc = vc; // hang around the reference for custom actions needed | |
BarStyle = UIBarStyle.Black; | |
//TintColor = SOMEUICOLOR; // Use to tint your buttons | |
// need to draw a proper clear context as image to fill the toolbar for iOS 5+ | |
RectangleF rect = new RectangleF(0, 0, 1, 1); | |
UIGraphics.BeginImageContext(new SizeF(1.0f,1.0f)); | |
CGContext context = UIGraphics.GetCurrentContext(); | |
UIColor.Clear.SetFill(); | |
context.FillRect(rect); | |
UIImage transparentImage = UIGraphics.GetImageFromCurrentImageContext(); | |
SetBackgroundImage(transparentImage, UIToolbarPosition.Any, UIBarMetrics.Default); | |
context.RestoreState(); | |
Frame = GetFrame (); // setup your frame as necessary | |
BindYourButtons(); // add and align your buttons to the toolbar | |
} | |
private void GetFrame() | |
{ | |
throw NotImplementedException; | |
} | |
private void GetButtons() | |
{ | |
throw NotImplementedException; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Gist is how I got a clear toolbar to finally work in a subclassed UIToolbar in MonoTouch for iOS 5.0+