我想使用可调整大小的图像作为我的工具栏背景图像,但由于某些原因代码无法正常工作。这里是我的图片大小:工具栏背景图像不会调整大小
Missions.png (320x64)
[email protected] (640x128)
[email protected] (1242x195)
这里是我的代码:
-(void)viewWillAppear:(BOOL)animated{
UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64);
UIImage *backgroundImage = [UIImage imageNamed:@"Missions.png"];
UIImage *resizableBackground = [backgroundImage resizableImageWithCapInsets:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f)];
-----[toolbar setBackgroundImage:[UIImage imageNamed:resizableBackground] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault]; -----------------------------
[self.view addSubview:toolbar];
}
我得到一个警告,对在“resizableBackground”虚线,上面写着:不兼容的指针类型发送“的UIImage *”以类型的参数 '的NSString *'
[工具栏了setBackgroundImage:resizableBackground forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault]。 – Sandeep 2015-01-09 20:54:04