Reputation: 151
I have added a UIView (containing within it a UIVisualEffectView - blur) as a subview of another view. I would like to animate the subview from its center outwards towards the edges in a radial fashion, like an expanding circle. This should reveal its superView below.
Here is my code:
self.blurView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, imageHeight)];
[superView addSubview: self.blurView];
UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = self.blurView.bounds;
[self.blurView addSubview:visualEffectButtonView];
Upvotes: 0
Views: 694
Reputation: 4196
If you want to maintain the frame:
[UIView animateWithDuration:0.5
delay:0.0
options: UIViewAnimationCurveEaseOut
animations:^{
viewToAnimate.transform = CGAffineTransformMakeTranslation(x,y);
viewToAnimate.alpha = 0.0f;
}completion:^(BOOL finished){
}];
Move it in any direction you like using the x,y coordinates (x moves left and right, y moves up and down, in each case whether the value is negative or positive respectively), e.g. x = 10, moves the view 10 pixels to the right.
Upvotes: 0
Reputation: 2099
[UIView animateWithDuration:3.0 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
//code with animation
self.blurView.frame = CGRectMake(self.blurView.frame.origin.x,
-self.blurView.frame.size.height,
self.blurView.frame.size.width,
self.blurView.frame.size.height);
} completion:^(BOOL finished) {
//code for completion
[self.blurView removeFromSuperview];
}];
Upvotes: 1
Reputation: 6067
By Using UIView Animation
[UIView animateWithDuration:0.5
delay:1.0
options: UIViewAnimationCurveEaseOut
animations:^{
visualEffectView.alpha = 0;
}completion:^(BOOL finished){
[visualEffectView removeFromSuperview];
}];
Upvotes: 0