SubView slide in animation, iphone

I have a UIview Containing two UIButtons.

    geopointView = [[UIView alloc] initWithFrame:CGRectMake(0, 350, 120, 80)];
    geopointView.backgroundColor = [UIColor greenColor]; 

    UIButton *showGeoPointButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
    showGeoPointButton.frame = CGRectMake(0, 0, 120, 40);
    showGeoPointButton.titleLabel.font = [UIFont systemFontOfSize:13.0];
    [showGeoPointButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[showGeoPointButton addTarget:self action:@selector(showPlaces:) forControlEvents:UIControlEventTouchUpInside];

    UIButton *SaveButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain] 
    SaveButton.frame = CGRectMake(0, 40, 120, 40);
    SaveButton.titleLabel.font = [UIFont systemFontOfSize: 15.0];
    [SaveButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [SaveButton addTarget:self action:@selector(savePlacePopUp) forControlEvents:UIControlEventTouchUpInside];

    [geopointView addSubview:showGeoPointButton];
    [geopointView addSubview:SaveButton];

I want to animate slide in of UIview when following method is called.

  • UIView animations with autoreverse
  • Change duration (speed) on a running animation
  • How to animate the width and height of a UIView in Xcode?
  • UIView Animation in Swift not working, wrong arguments error
  • How to animate removeFromSuperview
  • Having problems allowing interaction in UIView animation
  • -(void) showAnimation

    I tried to do it by following way but I can see no animation. How can I do it?

    -(void) showAnimation{
        [UIView animateWithDuration:10.0 animations:^{
            [self.view addSubview:geopointView];

    Thannks for any help in advance.

    Solutions Collect From Internet About “SubView slide in animation, iphone”

    You need to add the subview with a frame value that is where you want the animation to begin from (off-screen?) then change the frame value inside your animation block. The frame will change over the duration, causing the appearance of movement. The view must already be a subview – I don’t believe adding a subview is something you can animate, it makes no sense.

    -(void)showAnimation {
        [self.view addSubview:geopointView]
        geopointView.frame = // somewhere offscreen, in the direction you want it to appear from
        [UIView animateWithDuration:10.0 
                             geopointView.frame = // its final location