【问题标题】:UIToolBar lose translucent when clipsToBounds in iOS7.xiOS7.x中clipsToBounds时UIToolBar失去半透明
【发布时间】:2015-02-24 20:08:17
【问题描述】:

通常我使用 UIToolBar 来伪造实时模糊效果,它对我来说效果很好。但是有一个地方我需要一个圆角工具栏,但是,每当我设置cornerRadius和clipsToBounds时,半透明(模糊)效果就消失了,我的工具栏变得透明了。

这是我的代码:

UIToolbar *blurView = [[UIToolbar alloc] initWithFrame:self.bounds];
blurView.barStyle = UIBarStyleBlack;
blurView.layer.cornerRadius = self.height / 2;
blurView.clipsToBounds = YES;
[self insertSubview:blurView atIndex:0];

这是clipsToBounds = YES时的屏幕截图,角是圆的,但模糊消失了。

但是如果我comment clipsToBounds out,模糊效果又回来了,但角落不再圆润了。

更奇怪的是这个问题只发生在 iOS7.x 中,在 iOS8.x 中一切正常,代码完全相同。

如果您想知道,这里是它在 iOS8.x 上的外观以及在 iOS7.x 上的外观

我一直在 Stackoverflow 和 Google 上搜索,找不到任何线索。请帮忙!

【问题讨论】:

  • blurView.layer.cornerRadius = self.height / 2 - 0.5;

标签: ios ios7 uitoolbar


【解决方案1】:

试试blurView.layer.cornerRadius = self.height / 2 - 0.5;

【讨论】:

  • 那行得通...我不敢相信 iOS7 中的 UIToolbar 不采用四舍五入的数字,因为它是拐角半径...
猜你喜欢
  • 1970-01-01
  • 2014-05-27
  • 1970-01-01
  • 2013-09-28
  • 1970-01-01
  • 1970-01-01
  • 2013-12-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多