0
我在UIView中设置了一个椭圆形背景图像的自定义按钮。如何在UIButton中显示高分辨率可伸缩的背景图像?
在iPhone OS 3中,[UIImage:stretchableImageWithLeftCapWidth:topCapHeight:]工作正常。
但是,在iOS 4与iPhone 4(意味着高分辨率),背景图像不伸展。
这里是有问题的代码:
UIButton* btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setFrame:CGRectMake(0, 0 , 200 , 35)];
btn.titleLabel.font = [UIFont boldSystemFontOfSize:12];
[btn setTitle:@"Custom Button" forState:UIControlStateNormal];
UIImage* bgImg = [[UIImage imageNamed: @"buttonBg"] stretchableImageWithLeftCapWidth:6 topCapHeight: 6];
// butonBg.png : 46 x 35px
// [email protected] : 92 x 70px
[btn setBackgroundImage:bgImg forState:UIControlStateNormal];
[self.view addSubview:btn];
我缺少什么?这是一个缩放问题吗?
在此先感谢。