开发者

How to make a custom button that looks like a back button in NavigationBar? I mean the shape of the left side that is like an arrow

How to make a custom button that looks like a back button in NavigationBar? I mean the shape of the left side that is like an arrow. In the sense ho开发者_开发技巧w to set an image to back button?


  1. Use UIButtonTypeCustom style.
  2. Set required image (with shape of the left side that is like an arrow) to background property.


UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(100,50,100,30);//set ur required frame
[backBtn setBackgroundImage:[UIImage imageNamed:@"backImage.png"] forState:UIControlStateNormal]; //Add back Like image
//use this button


The best way I've found is to use a stretchable button with a defined leftCapWidth to account for the pointy side of your button. That way if you ever need to change the label from "Back" "New Sales Customers" you don't need to re-export the background Image.

I even think they created a convenience extension for you:

var button = backButtonImage.StretchableButton(5, 0);
view.AddSubView(button);

How to make a custom button that looks like a back button in NavigationBar? I mean the shape of the left side that is like an arrow

http://idevrecipes.com/2010/12/08/stretchable-images-and-buttons/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜