I want to put a square button in the UINavigationBar, much like the + button, but with an image I have. When i do this:
self.navigationIt开发者_运维百科em.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"settings wheel.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(prefsPressed)];
It just stretches the image out and makes a long button. Any ideas how to make it square?
UIBarButtonItem has a width property you can set. I'm not sure if that will do the trick for you, though. If not, you can go with creating a custom UIView (e.g. a UIImageView) and setting it using the initWithCustomView
method:
See here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIBarButtonItem_Class/Reference/Reference.html
精彩评论