在我的情节提要上,我添加了一个点击图标作为UIImageView
,在代码中我通过创建圆形视图并放大和淡化它们使其脉动并添加“涟漪”效果。我添加了这些圆形视图viewDidLoad
,insertSubview:belowSubview:
但无论出于何种原因,它们仍然出现在顶部。为什么是这样?
这是我正在使用的代码:
// For the tap animation at the top
UIView *topTapRipple1 = [[UIView alloc] initWithFrame:(CGRectMake(157, 50, 13.0, 13.0))];
topTapRipple1.backgroundColor = [UIColor clearColor];
topTapRipple1.layer.cornerRadius = topTapRipple1.bounds.size.height/2;
topTapRipple1.layer.borderColor = [UIColor colorWithRed:0.886 green:0.886 blue:0.886 alpha:1].CGColor;
topTapRipple1.layer.borderWidth = 1.0;
[self.view insertSubview:topTapRipple1 belowSubview:self.middle];
UIView *topTapRipple2 = [[UIView alloc] initWithFrame:(CGRectMake(157, 50, 13.0, 13.0))];
topTapRipple2.backgroundColor = [UIColor clearColor];
topTapRipple2.layer.cornerRadius = topTapRipple2.bounds.size.height/2;
topTapRipple2.layer.borderColor = [UIColor colorWithRed:0.886 green:0.886 blue:0.886 alpha:1].CGColor;
topTapRipple2.layer.borderWidth = 1.0;
[self.view insertSubview:topTapRipple2 belowSubview:self.middle];
如您所见,我在视图下方添加了self.middle
视图,即UImageView
.
我希望涟漪从它后面开始,但它仍然看起来像这样:
当图像如下所示时,您可以在图像顶部看到圆圈:
包含问题的示例项目:http: //cl.ly/2v2G053t3t0z