I have created back image same as default back "< back
" used by Navigation controller. My problem is I don't know the exact frame of back button. Since I am using stretchable image, I need to fix the stretch, bu the caption of button is not coming exactly in center. here is my code
`UIButton* btnBack = [[UIButton alloc] initWithFrame: CGRectMake( 0.0, 0.0, 65, 32.0 )]; btnBack.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; btnBack.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
UIImage *image = [UIImage imageNamed:@"btn_back-1.png"];
// Make a stretchable image from the original image
UIImage *stretchImage =
[image stretchableImageWithLeftCapWidth:15 topCapHeight:0.0];
// Set the background to the stretchable image
[btnBack setBackgroundImage:stretchImage forState:UIControlStateNormal];
// Make the background color clear
btnBack.backgroundColor = [UIColor clearColor];
// Set the font properties
[btnBack setTitleShadowColor:[UIColor blackColor] forState:UIControlStateNormal];
[btnBack.titleLabel setFont:[UIFont boldSystemFontOfSize:13]];
[btnBack setTitle:@"Back" forState:UIControlStateNormal]; `
Please help me know what I am doing worn here. Thanks