如果文章对您有用,麻烦顺手点一下文章的广告吧~

东东

自定义UINavigationBar
不使用UINavigationController用代码自定义UINavigationBar和样式UINaviga...
扫描右侧二维码阅读全文
13
2015/08

自定义UINavigationBar

不使用UINavigationController用代码自定义UINavigationBar和样式

屏幕快照 2015-08-13 14.27.54.png


UINavigationBar *bar=[[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 60)];
    UIBarButtonItem *leftbutton=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"left_view.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showLeftView)];
     UIBarButtonItem *rightButton=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"left_view.png"] style:UIBarButtonItemStylePlain target:self action:@selector(initPopMenu)];
    UINavigationItem *item=[[UINavigationItem alloc]initWithTitle:@"首页"];
    [item setLeftBarButtonItem:leftbutton];
    [item setRightBarButtonItem:rightButton];
    [bar pushNavigationItem:item animated:false];
    [self.View addSubview:bar];

如果没有效果,是因为你没有定义left_view.png这个图片

Last modification:January 1st, 1970 at 08:00 am
如果觉得我的文章对你有用,请随意打赏: ☞已打赏列表

Leave a Comment