iOS -- 解决iOS11中navigationBar上使用initWithCustomView按钮图片错位 frame无效


在iOS11上当使用如下代码设置时

 

  1. UIButton *shareButton = [UIButton buttonWithType:(UIButtonTypeCustom)];  
  2.  shareButton.frame = CGRectMake(0, 0, 30, 30);  
  3.  shareButton.backgroundColor = [UIColor blueColor];  
  4.  [shareButton setImage:[UIImage imageNamed:@"mv_actionIconSaveToAlbum"]  forState:(UIControlStateNormal)];  
  5.  UIBarButtonItem *rightBtnItem = [[UIBarButtonItem alloc] initWithCustomView:shareButton];  
  6.  self.navigationItem.rightBarButtonItem = rightBtnItem;  


如果图片大小大于按钮设置的大小 ,设置的button的frame将不起作用。系统将采用最大区域展示。图片大小小于设置的button的frame时 不会出现这个问题。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM