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?
- Use
UIButtonTypeCustom
style. - 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);
http://idevrecipes.com/2010/12/08/stretchable-images-and-buttons/
精彩评论