首页 > 其他 > 详细

关于自定义导航条UIBarButtonItem偏移的问题

时间:2015-08-08 19:52:45      阅读:180      评论:0      收藏:0      [点我收藏+]

在自定义导航条左按钮的时候发现按钮的位置向右偏移,下面给出了解决方法

主要还依赖于UIButton的属性设置

//  设置导航条的左按钮

    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];

    leftButton.frame = CGRectMake(0, 0, 32, 26);

    leftButton.imageEdgeInsets = UIEdgeInsetsMake(0, -13, 0, 0);//  设置按钮图片的偏移位置(向左偏移)

    [leftButton setImage:[UIImage imageNamed:@"shouye-cehua"] forState:UIControlStateNormal];

    [leftButton addTarget:self action:@selector(handleLeftButtonAction:) forControlEvents:UIControlEventTouchUpInside];

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];

关于自定义导航条UIBarButtonItem偏移的问题

原文:http://www.cnblogs.com/wangguimin/p/4713739.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!