I have a UIWebView in a view but what i want to do is hide the background but still show the UIWebView. Im new to Mobile development. I have researched and used code from net but cannot find a solution can anyone please help. Thanks.
[UIView animateWithDuration:0.3 animations:^() {
view.alpha = 0.0;
}];
I have got the UIWebView to fade out but thats not what i want, basically the UIWebView still needs to be visible but the background to be faded out or make the background hidden but not the UIWebView
I have also tried:
[UIView beginAnimations: #"Fade Out" context:nil];
[UIView setAnimationDuration:2.0];
[self.view setAlpha:0.0f];
[UIView commitAnimations];
Seems to only fade out the UIWebView
You are setting the alpha on the view itself, which will be applied to the view and its subviews. Change its background color
[UIView animateWithDuration:0.3f animations:^{
view.backgroundColor = [UIColor clearColor];
}];
Related
I would like to change the content of my titleView in the navigationBar to display different kinds of information, for instance a UIsegmentedControl or a UILabel.
The change of the information should be a done with a transition (segmentedControl fades out and label fades in).
I tried to add multiple UIViews in the titleView and animate the alpha value, but it's not working.
[self.navigationItem.titleView addSubview:_mainSegmentedControl];
So I tried to change the content during the animation but since the value can't be animated it will be called immediately:
[UIView animateWithDuration:0.2 animations:^{
_filterSegmentedControl.alpha = 0.0f;} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3 animations:^{
self.navigationItem.titleView = _mainSegmentedControl;
_mainSegmentedControl.alpha = 1.0f;
}];
}];
Any suggestions?
I implemented this method to make flash button, but doing the touch of the button stops working well.
-(void)imageAnimation:(UIButton *)imagen{
[UIView animateWithDuration:.5 animations:^{
imagen.alpha = 1.0;
} completion:^(BOOL finished){
[UIView animateWithDuration:.5 delay:0.5 options:0 animations:^{
imagen.alpha = 0.0;
} completion:^(BOOL finished){
[self imageAnimation:imagen];
}];
}];
}
You know as I can do to make the image flickers button but the button always is active and visible touch that works well?
How about animating a UIImageView's alpha and using a transparent UIButton over it? Alternatively, you could use a UITapGestureRecognizer on the UIImageView itself, though I think the alpha=0 issue will reoccur in this scenario as well.
I've got a UILabel that slides in and out of view, but after it slides back in it disappears. I want it to persist.
How can I achieve this? Also, why does this happen?
Here's the code:
[UIView animateWithDuration:0.1
delay:0.0
options:UIViewAnimationOptionAutoreverse
animations:^{
[self.listLabel setFrame:CGRectMake(325, 141, 320, 181)];
}
completion:nil];
Thanks.
In official documentation
UIViewAnimationOptionAutoreverse
Run the animation backwards and forwards. Must be combined with the UIViewAnimationOptionRepeat option.
Why don't you use UIViewAnimationOptionCurveEaseOut and UIViewAnimationOptionCurveEaseIn animation option for your label?
Just set your label's frame.origin.x = [outside the right side of it's superview's bound]
and set it back to it's original position when you want to slide-In again using EasyOut animation.
Here's something what I'm talking about...
CFRect frame = self.listLabel.frame;
//Point to hide your label by sliding it outside the right side of it's parent's view.
// mask or clipToBounds of parent's view must be YES
frame.origin.x = [self.listLabel.superview.frame.size.width];
[UIView animateWithDuration:0.1
delay:0.0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
[self.listLabel setFrame:frame];
}
completion:nil];
And When you want to slide back in, use opposite animation and label's original position, of course you need to store it's original position somewhere so you could slide-in it back.
[UIView animateWithDuration:0.1
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
[self.listLabel setFrame:label_original_frame];
}
completion:nil];
UIViewAnimationOptionAutoreverse is designed for a cyclical animation. To just bounce something offscreen and back, you should just write it as 2 animations:
CGRect originalFrame = self.listLabel.frame;
[UIView animateWithDuration:0.05
delay:0.0
options:UIViewAnimationOptionLayoutSubviews
animations:^{
[self.listLabel setFrame:CGRectMake(325, 141, 320, 181)];
}
completion:^(BOOL finished){
[UIView animateWithDuration:0.05
delay:0.0
options:UIViewAnimationOptionLayoutSubviews
animations:^{
[self.listLabel setFrame:originalFrame];
}
completion:nil];
}
];
As there still seems to be no valid answer, I propose a (now possible) approach:
In Xcode 6, with the app running in the simulator, go to "Debug" in the top bar, select "View Debugging" and "Capture View Hierarchy". Then go and search your missing Label. You can also see properties etc. of the Label in the right Xcode bar.
I have the current problem:
From an NSObject i'm creating / loading and animating a view:
[UIView beginAnimations:#"slidein" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDidStopSelector:#selector(animationDidStop:finished:context:)];
[content.view setAlpha:1.0];
for (UIView *view in content.view.subviews) {
[view setAlpha:1];
}
[content.view setFrame:CGRectMake(0, 0, self.contentEnclosure.size.width, self.contentEnclosure.size.height)];
[UIView commitAnimations];
My problem is that, when orientation changes, my animated view disappears. If i make my view appear again, the orientation settings (frame size) are correct, so i'm guessing, that the resizing mask is applied correctly, i just don't understand what needs to be done, for my view not to disappear.
Use NSLog and check the new self.view.frame.origin.x and y respectively after the orientation.
Then set the frame according to the requirement.
Also, check for resizing mask. Try using UIViewAutoresizingFlexibleRightMargin/LeftMargin to suit your requirements.
I was trying to implement something resembling the iBook store on iPad.
When you tap on a book cover it will flip and scale in one fluid motion, from the book cover to an empty background - which then loads the content.
I have tried different approaches, first flipping, then scaling, I tried wrapping the transitionFromView inside the animateWithDuration block, but i can't get it to look properly. It will either do one then the other, or in the last case do one, then 'flickr' and do nothing.
[UIView transitionFromView:fromView
toView:toView
duration:0.8
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
if (finished) {
[UIView animateWithDuration:0.4
animations:^{[fromView setFrame:originFrame];}
completion:^(BOOL finished){}];
}
}];
Blocks are great for animations, no doubt!
But how can I both flip and scale at the same time?
Thanks in advance.
I have been able to produce this effect using non-block animations by performing the flip on a view containing the views you switch between.
CGRect endFrame; //The frame of the view after animation
UIView *sview; //The superview containing the first view
UIView *view1; //The first view, to be removed from sview
UIView *view2; //The second view, to be added to sview
view2.frame = view1.frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:sview cache:YES];
[view1 removeFromSuperview];
[sview addSubview:view2];
sview.frame = endFrame;
[UIView commitAnimations];
For this to work, the autosizing mask on view2 must be resizable in width and height.