Today in the writing program to open the function of the Web page, write the toolbar when the System icon found there is no back button, because I this is a static library project, it is not possible to get a picture on their own, or use this library when you have to attach a piece, after an afternoon search, finally found a more reliable, This guy just used the code to draw out an arrow (say if it is other irregular graphics to do?) ), or Google is working ah, Baidu is very very very ... Garbage. Code example:drawing the IPhone back Button (reprint)
Recently, I had need to provide a back button similar to the one used on Mobile Safari for a consulting project.
Many of the buttons used in the built-in IPhone applications is made available via the SDK with built in button types and Graphics. Unfortunately, the back button was not one of the these.
Because I needed to display the toolbar button from inside a static library which can does include images, I had to render The back arrow directly in code.
Since This is a bit time consuming, I thought I would share in hopes that it saves someone else a little bit of time.
-(CGCONTEXTREF) createcontext{//Create the bitmap contextcgcolorspaceref colorspace = Cgcolorspacecreatedevicergb (); Cgcontextref context = Cgbitmapcontextcreate (nil,27,27,8,0,colorspace,kcgimagealphapremultipliedlast); Cfrelease (colorspace); return context;} -(CGIMAGEREF) Createbackarrowimageref{cgcontextref context = [Self createcontext];//set the fill colorcgcolorref FillColor = [[Uicolor blackcolor] cgcolor]; Cgcontextsetfillcolor (Context, cgcolorgetcomponents (FillColor)); Cgcontextbeginpath (context); Cgcontextmovetopoint (context, 8.0f, 13.0f); Cgcontextaddlinetopoint (context, 24.0f, 4.0f); Cgcontextaddlinetopoint (context, 24.0f, 22.0f); Cgcontextclosepath (context); Cgcontextfillpath (context);//Convert the context into a cgimagerefcgimageref image = Cgbitmapcontextcreateimage ( context); Cgcontextrelease (context); return image;} -(Uibarbuttonitem *) backbutton{cgimageref thecgimage = [self createbackarrowimageref]; UIImage *backimage = [[UIImage alloc] initwithcgimage:thecgimage]; Cgimagerelease (Thecgimage); Uibarbuttonitem *backbutton = [[Uibarbuttonitem alloc] InitWithImage:backImagestyle:UIBarButtonItemStylePlaintarget : self.webviewaction: @selector (goBack)]; [Backimage release], backimage = Nil;return [Backbutton autorelease];}
UIWebView plus Safari style forward back button (go)