怎么给UIBarButton添加一个图片
这是我的代码:UIBarButtonItem*settingsBtn=[[UIBarButtonItemalloc]initWithImage:[UIImageimage...
这是我的代码:UIBarButtonItem *settingsBtn= [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_prefs.png"] style:UIBarButtonItemStylePlain target:self action:@selector(openSettings:)];[[self navigationItem] setLeftBarButtonItem:settingsBtn];[settingsBtn release];我能看到我的图片,但也能看到按钮的边框,我希望能把边框去掉,怎么实现?
展开
2个回答
展开全部
UIImage* image= [UIImage imageNamed:@"some-image.png"];CGRect frame= CGRectMake(0, 0, image.size.width, image.size.height);UIButton* someButton= [[UIButton alloc] initWithFrame:frame];[someButton setBackgroundImage:image forState:UIControlStateNormal];[someButton setShowsTouchWhenHighlighted:YES];UIBarButtonItem* someBarButtonItem= [[UIBarButtonItem alloc] initWithCustomView:someButton];[self.navigationItem setRightBarButtonItem:someBarButtonItem];[someBarButtonItem release];[someButton release];
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
UIImage* image= [UIImage imageNamed:@"some-image.png"];CGRect frame= CGRectMake(0, 0, image.size.width, image.size.height);UIButton* someButton= [[UIButton alloc] initWithFrame:frame];[someButton setBackgroundImage:image forState:UIControlStateNormal];[someButton setShowsTouchWhenHighlighted:YES];UIBarButtonItem* someBarButtonItem= [[UIBarButtonItem alloc] initWithCustomView:someButton];[self.navigationItem setRightBarButtonItem:someBarButtonItem];[someBarButtonItem release];[someButton release]; 查看原帖>>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询