iOS 去掉系统bar自带的线

去掉bar自带的线有两种方法,
第一种:那条线是阴影,shadow,阴影一般都是在控件的bounds之外的,我们沿着bounds进行裁剪,阴影都没了。
//去掉阴影,目的是为了去掉上方的线
toolbar.clipsToBounds = YES;

另一种方法肯定对UIToolbar有效,其他的bar没仔细看,系统提供了下面这个方法
/* Default is nil. When non-nil, a custom shadow image to show instead of the default shadow image. For a custom shadow to be shown, a custom background image must also be set with -setBackgroundImage:forToolbarPosition:barMetrics: (if the default background image is used, the default shadow image will be used).
 */
- (void)setShadowImage:(UIImage *)shadowImage forToolbarPosition:(UIBarPosition)topOrBottom NS_AVAILABLE_IOS(6_0) UI_APPEARANCE_SELECTOR;
 如果没有设置,就会使用系统默认的阴影图片,我们设置一下就可以了。 
[toolBar setShadowImage:[UIImage new] forToolbarPosition:UIBarPositionTop];
特别注意一下括号里面的内容
if the default background image is used, the default shadow image will be used
如果使用了default background image,default shadow image也会被使用,也就是仅仅使用
[toolBar setShadowImage:[UIImage new] forToolbarPosition:UIBarPositionTop];
是没有效果的。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值