开发者

Problem with setting background of UINavBar background

开发者 https://www.devze.com 2023-03-30 03:41 出处:网络
I am using the following code to set the background of the UINavBar self.navigationController.navigationBar.layer.contents=(id)[UIImage imageNamed:@\"topbar-nonretina.png\"].CGImage;

I am using the following code to set the background of the UINavBar

self.navigationController.navigationBar.layer.contents=(id)[UIImage imageNamed:@"topbar-nonretina.png"].CGImage;

However, sometimes I am getting the following error :

property `contents` not found on object of type `CALayer`

Can anyone kindly tel开发者_运维知识库l me whats happening here ? Thanks.


Probably cause you're not including QuartzCore in some file.

#include <QuartzCore/QuartzCore.h>

CALayer is defined there, so if you don't include that file, the compiler doesn't know that the layer property of navigationBar has a contents property itself

0

精彩评论

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