UIbarbuttonItem *backbutton = [[UIbarbuttonItem alloc] initWithImage:[UIImage imagenamed:@"back.png"] style:UIbarbuttonItemStylePlain target:self action:@selector(backAction)]; self.navigationItem.leftbarbuttonItem = backbutton;
它工作正常,但按钮出现边框.我该如何解决这个问题?
UPDATE
我找到了解决方案
UIbutton *button = [[UIbutton alloc] initWithFrame:CGRectMake(0,25,25)]; [button setimage:[UIImage imagenamed:@"back.png"] forState:UIControlStatenormal]; [button addTarget:self action:@selector(buttonFavoriteClicked) forControlEvents:UIControlEventtouchUpInsIDe]; UIbarbuttonItem *back = [[UIbarbuttonItem alloc] initWithCustomVIEw:button]; [button release];
self.navigationItem.leftbarbuttonItem = back;解决方法 尝试这个.
UIbutton *backbutton = [[UIbutton alloc] initWithFrame:CGRectMake(0,button_wIDth,button_height)];[backbutton setimage:[UIImage imagenamed:@"back.png"] forState:UIControlStatenormal];[backbutton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventtouchUpInsIDe];self.navigationItem.leftbarbuttonItem = [[UIbarbuttonItem alloc] initWithCustomVIEw:backbutton];总结
以上是内存溢出为你收集整理的xcode – 将自定义按钮添加到没有边框的导航控制器全部内容,希望文章能够帮你解决xcode – 将自定义按钮添加到没有边框的导航控制器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)