Here's an example that creates a toolbar button from the Facebook logo. Create a pointer to an image (file already added to xCode), create a custom button, change the size of the button to match the image, set image of button, create toolbar button from button view.
UIImage *faceImage = [UIImage imageNamed:@"facebook.png"];
UIButton *face = [UIButton buttonWithType:UIButtonTypeCustom];
face.bounds = CGRectMake( 0, 0, faceImage.size.width, faceImage.size.height );
[face setImage:faceImage forState:UIControlStateNormal];
UIBarButtonItem *faceBtn = [[UIBarButtonItem alloc] initWithCustomView:face];
2 NavBaritem的 图片确实改过来了
IBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"image.png"] style:UIBarButtonItemStylePlain target:self action:@selector(pp:)]
3.
UIImage *faceImage = [UIImage imageNamed:@"nav_back.png"]; UIButton *face = [UIButton buttonWithType:UIButtonTypeCustom]; face.bounds = CGRectMake( 0, 0, faceImage.size.width, faceImage.size.height ); [face setImage:faceImage forState:UIControlStateNormal]; [face addTarget:self action:@selector(clickLeftButton) forControlEvents:UIControlEventTouchDown]; UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithCustomView:face];