iOS 去掉系统bar自带的线

来源:互联网 发布:数据库完整性检查 编辑:程序博客网 时间:2024/05/16 01:49
去掉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
原创粉丝点击