开发者

iPhone SDK: Nav button items appear too large

I am testing a nav based app on an older iTouch that has 3.1.3 loaded. The problem is that the nav buttons size (which use custom images) are too large for the nav bar. This is not the case on 4.0.

Any ideas? Below is the code I am using to create them.

    //add done bar button - goes to email
UIButton *btnDone = [UIButton buttonWithType:UIButtonTypeCustom];  
UIImage *imageDoneBtn = [[UIImage imageNamed:@"ButtonDone.png"]  
                               stretchableImage开发者_如何学GoWithLeftCapWidth:10 topCapHeight:10];  
[btnDone setBackgroundImage:imageDoneBtn forState:UIControlStateNormal];  
[btnDone addTarget:self action:@selector(email:)  
        forControlEvents:UIControlEventTouchUpInside];
    btnDone.adjustsImageWhenDisabled = NO;
    btnDone.adjustsImageWhenHighlighted = NO;   
btnDone.frame = CGRectMake(0, 0, 49, 30);  
UIBarButtonItem *btnItemDone = [[[UIBarButtonItem alloc]  
                                       initWithCustomView:btnDone] autorelease];  
self.navigationItem.rightBarButtonItem = btnItemDone; 


I ran into the same problem (but i'm creating my buttons in Interface Builder). I had my png file set in the "Image" field, once I moved it to the "Background" field they were sized properly on 3.1.3

your using setBackgroundImage, so it should have worked I would think. Maybe try creating your button in IB?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜