Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9111285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:28:04+00:00 2026-06-17T03:28:04+00:00

I am attempting to make an image view ( logo below) slide upwards by

  • 0

I am attempting to make an image view (logo below) slide upwards by 100 pixels. I am using this code, but nothing happens at all:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3];
logo.center = CGPointMake(logo.center.x, logo.center.y - 100);
[UIView commitAnimations];

This code is in the viewDidLoad method. Specifically, the logo.center = ... is not functioning. Other things (like changing the alpha) do. Maybe I’m not using the right code to slide it upwards?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:28:06+00:00Added an answer on June 17, 2026 at 3:28 am

    For non-autolayout storyboards/NIBs, your code is fine. By the way, it’s now generally advised that you animate using blocks:

    [UIView animateWithDuration:3.0
                     animations:^{
                         self.logo.center = CGPointMake(self.logo.center.x, self.logo.center.y - 100.0);
                     }];
    

    Or, if you want a little more control over options and the like, you can use:

    [UIView animateWithDuration:3.0
                          delay:0.0
                        options:UIViewAnimationCurveEaseInOut
                     animations:^{
                         self.logo.center = CGPointMake(self.logo.center.x, self.logo.center.y - 100);
                     }
                     completion:nil];
    

    But your code should work if you’re not using autolayout. It’s just that the above syntax is preferred for iOS 4 and later.

    If you’re using autolayout, you (a) create an IBOutlet for your vertical space constraint (see below), and then (b) you can do something like:

    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
    
        static BOOL logoAlreadyMoved = NO; // or have an instance variable
    
        if (!logoAlreadyMoved)
        {
            logoAlreadyMoved = YES; // set this first, in case this method is called again
    
            self.imageVerticalSpaceConstraint.constant -= 100.0;
            [UIView animateWithDuration:3.0 animations:^{
                [self.view layoutIfNeeded];
            }];
        }
    }
    

    To add an IBOutlet for a constraint, just control-drag from the constraint to your .h in the assistant editor:

    add IBOutlet for vertical constraint

    By the way, if you’re animating a constraint, be sensitive to any other constraints that you might have linked to that imageview. Often if you put something right below the image, it will have its constraint linked to the image, so you may have to make sure you don’t have any other controls with constraints to your image (unless you want them to move, too).

    You can tell if you’re using autolayout by opening your storyboard or NIB and then selecting the “file inspector” (the first tab on the right most panel, or you can pull it up by pressing option+command+1 (the number “1”)):

    autolayout on

    Remember, if you planning on supporting pre-iOS 6, make sure to turn off “autolayout”. Autolayout is an iOS 6 feature and won’t work on earlier versions of iOS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to make a parallax page, but when I change the placeholder image
Have been attempting to make a custom sidebar similar to the image linked below.
My Code is posted Below. I am creating an image, and attempting to add
I am attempting to make my first mobile website by just using a different
I was attempting to make some expression templates as an answer to this question
I'm attempting to make use of the UIDocumentInteractionController mechanism in iPhone OS 3.2, but
I am attempting to make a GET request for a single image on another
This is my first blackberry app and I am attempting to make a simple
I'm attempting to make some simple 9patch PNG photos for using with ImageButton views,
I'm attempting to learn some Python and Tkinter. The sample code below is intended

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.