自定义UIBarButtonItem

{app.params.name}} {app.params.name}} {app.params.name}}

因为按钮的要求,好友导航的限制,想着自己自定义一个barbuttonitem,如下

self.leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[self.leftBtn setFrame:CGRectMake(10.0, 5.0, 70.0, 30.0)];
[self.leftBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
[self.leftBtn setTitle:@"返回" forState:UIControlStateNormal];
[self.leftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self.leftBtn setTintColor:[UIColor redColor]];
//    [self.leftBtn setImage:[UIImage imageNamed:@"back_60_30"] forState:UIControlStateNormal];

self.leftBtn.layer.cornerRadius = 10.0;
self.leftBtn.layer.borderWidth = 1.0;

[self.leftBtn addTarget:self
           action:@selector(returnToPrev)
 forControlEvents:UIControlEventTouchUpInside];
[self.leftBtn setTag:1];
[self.navigationBar addSubview:self.leftBtn];


版权声明

davidzhang 创作并维护的 Gowhich 博客采用 创作共用保留署名-非商业-禁止演绎4.0国际许可证。

本文首发于 Gowhich 博客( https://www.gowhich.com ),版权所有,侵权必究。

本文永久链接: https://www.gowhich.com/blog/127

comments powered by Disqus