I Have 4 images. I want to add images in UIView one by one.
please give me any idea. How to add images array in UIView.
It is not clear from your question but i am guessing you wan to show images in your view one by one after some time delays... If it is what you want you van get it by
[self performSelector:#selector(callFunction) withObject:nil afterDelay:0 ];
[self performSelector:#selector(callFunction2) withObject:nil afterDelay:k_AnimateTime ];
[self performSelector:#selector(callFunction3) withObject:nil afterDelay:2*k_AnimateTime ];
in the Function
imageview = [[[UIImageView alloc] initWithFrame:CGRectMake(x,y,w,h)]autorelease];
imageview.image = [[UIImage imageNamed: [NSString stringWithString:name]]autorelease];
[self.view addSubview:imageview];
imageview.frame = CGRectMake(imageview.frame.origin.x, (imageview.frame.origin.y), imageview.frame.size.width, imageview.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
//[UIView setAnimationWillStartSelector:#selector(Transform2)];
[UIView setAnimationDuration:k_AnimateTime];
[UIView setAnimationBeginsFromCurrentState:YES];
//[UIView setAnimationDidStopSelector:#selector(increaseCount)];
imageview.frame = CGRectMake(imageview.frame.origin.x - Ex, (imageview.frame.origin.y - Ey), imageview.frame.size.width, imageview.frame.size.height);
[UIView commitAnimations];
[self.view addSubview:imageview];
}
Related
I am trying to go from one view controller to another with the use of page curl up animation; but when my second controller loads, it hides the collection view from it. This is my code:
OffersVC *Offers = [[OffersVC alloc]init];
Offers = [self.storyboard instantiateViewControllerWithIdentifier:#"Offers"];
[UIView beginAnimations:#"flipview" context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[self.view addSubview:Offers.view];
[UIView commitAnimations];
Try to add animation as below and check
UIView *mainview = self.view.window;
OffersVC *Offers = [[OffersVC alloc]init];
Offers = [self.storyboard instantiateViewControllerWithIdentifier:#"Offers"];
[UIView transitionWithView:mainview
duration:kAnimationViewTransition
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
[self.navigationController.view removeFromSuperview];
[mainview addSubview: offers.view];
}
completion:^(BOOL finished) {
[self presentModalViewController:offers animated:NO];
}
];
i got a button to show an image in the UIImageView. what i need to do is to get this image to fade out by itself in 2 seconds, is it possible to do so?
here is my code on the button:
- (IBAction)A {
UIImage *Img = [UIImage imageNamed:#"AString.png"];
[ImageView setImage:Img];
}
thank you in advance...
Try this:
- (IBAction)A
{
UIImage *Img = [UIImage imageNamed:#"AString.png"];
[ImageView setImage:Img];
Img.hidden = NO;
Img.alpha = 1.0f;
[UIView animateWithDuration:2 delay:0 options:0 animations:^{
Img.alpha = 0.0f;
} completion:^(BOOL finished) {
Img.hidden = YES;
}];
}
Try this code :
yourImageView.hidden = YES;
[UIView transitionWithView:yourImageView
duration:2
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[self.view layoutIfNeeded]; // Called on parent view
}
completion:NULL];
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
UIImageView *circleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"face.png"]];
circleView.frame = CGRectMake(0, 0, 200, 200);
circleView.layer.cornerRadius = 100;
circleView.center = self.view.center;
[self.view addSubview:circleView];
circleView.transform = CGAffineTransformMakeScale(0, 0);
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:.5 initialSpringVelocity:1 options:0 animations:^{
circleView.transform = CGAffineTransformMakeScale(1, 1);
} completion:nil];
As you can see, I made a view called circleView in this animation method. Then, I created a touchesBegan method and I want to run through the animation again when touching the screen. How should I do that?
As Sujay said, create a new method and put below lines inside that method. Call that method from touchBegan method.
circleView.transform = CGAffineTransformMakeScale(0, 0);
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:.5 initialSpringVelocity:1 options:0 animations:^{
circleView.transform = CGAffineTransformMakeScale(1, 1);
} completion:nil];
I did it. I created 2 properties and I made an animation where it gets small, then another animation that makes to make it bigger.
Hi guys I have 2 UIViews. First UIView is moving via animation, but when it reaches second UIView it moving under it. How to move First UIView over the second UIView?
Here is my code (self.openView is first UIView, self.showView is second UIView):
- (void)cardImage:(NSString *)cardContent{
self.cardOpenImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:#"%#.png",cardContent]]];
self.cardOpenImage.frame = CGRectMake(0, 0, self.openView.frame.size.width, self.openView.frame.size.height);
UIImageView *cardBacksImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"cardbacks.png"]];
cardBacksImage.frame = CGRectMake(0, 0, self.openView.frame.size.width, self.openView.frame.size.height);
[self.openView addSubview:cardBacksImage];
[UIView transitionFromView:cardBacksImage
toView:self.cardOpenImage
duration:1
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
[self moveToLeft:nil finished:nil context:nil];
}];
}
- (void)moveToLeft:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[UIView animateWithDuration:1.0
delay:0
options:(UIViewAnimationCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction)
animations:^{
[UIView setAnimationDelegate:self];
self.openView.center = CGPointMake(247, 180);
}
completion:^(BOOL finished){
NSLog(#"Move to left done");
}];
}
[self.openView.superview bringSubviewToFront:self.openView];
Will bring self.openView to the top of it's superview's view hierarchy. This will work assuming both of your UIViews are subviews of the same superview.
in my main view controller the button action is
-(IBAction)ChangeImage
{
UIImage *guns = [UIImage imageNamed:#"guns.png"]; // load our image resource
imageView = [[UIImageView alloc] initWithImage:guns];
NSLog(#"kaam hua..??");
[self.view addSubview:imageView];
[UIView transitionFromView:self.view
toView:imageView
duration:3.0f
options:UIViewAnimationOptionTransitionCrossDissolve
completion:nil];
NSLog(#"hfhjlkhbjhdfcvkbjnlkhgj");
}
i want to view the animation in slide view
is there any method to do this
can i chnage the UIViewAnimationOptionTransitionCrossDissolve to another one to show slide view
You can use UIViewAnimationOptionCurveEaseIn in animation option,
Try this,
CGRect or=self.view.frame;
CGRect basketTopFrame = self.view.frame;
basketTopFrame.origin.x = basketTopFrame.size.width;
self.view.frame = basketTopFrame;
[UIView animateWithDuration:0.2
delay:0.0
options: UIViewAnimationOptionCurveEaseIn
animations:^{
[self.view addSubview:imageView];
}
completion:^(BOOL finished){
NSLog(#"Done!");
}];