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

  • SEARCH
  • Home
  • 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 8028353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:06:47+00:00 2026-06-05T00:06:47+00:00

In the app I’m making, I’m trying to make a button start offscreen and

  • 0

In the app I’m making, I’m trying to make a button start offscreen and move onscreen. I’m not sure how to start with the button offscreen, but I know that once I figure that out, I can do something like the code below:

[UIView beginAnimation:@"animate" context: nil];
[UIView setAnimationDuration:3];
self.myButton.frame = CGRectMake (20, 100, 40, 80);
//Other animations
[UIView commitAnimations];

Additionally, in the line [UIView beginAnimation:@"animate" context:nil];, is the context parameter asking for a CGContextRef?

  • 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-05T00:06:48+00:00Added an answer on June 5, 2026 at 12:06 am

    I assume that you are asking how to get the button to animate from offscreen to onscreen, to do this just set the buttons origin position to coordinates that are located offscreen.

    self.myButton.frame = CGRectMake(-80, 100, 40, 80);
    

    Once you have done this you can just use the code you posted to animate onto the screen. Keep in mind that the button will move from the first position to the second, meaning that if you used the coordinates i used the button would move onto the screen from the left side without the y position changing. Keep in mind that the further offscreen you put the button the faster it will have to move to get onto the screen in the time allotted in the setAnimationDuration.

    So to animate onto screen from the left

    self.myButton.frame = CGRectMake(-80, 100, 40, 80);
    // begin animation block    
    [UIView beginAnimations:@"animate" context: nil];
    [UIView setAnimationDuration:3];
    self.myButton.frame = CGRectMake (20, 100, 40, 80);
    // commit frame changes to be animated
    [UIView commitAnimations];
    

    Also, if the button was previously on the screen it will seem to teleport off the screen and then slide back on when that code is used.

    Oh, and to answer your question about the context, no it doesn’t have to be a CGContextRef, it can be any data type (as long as its an object and not a primitive). Its basically the data that gets passed to the delegate when the animation occurs.

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

Sidebar

Related Questions

App runs on simulator on my MacBook Air, but not on iMac. I have
My app runs fine in the ios 4.3 simulator, but not the ios 5
My app must NOT auto -rotate at all. But it includes a screen which
app link: http://itunes.apple.com/en/app/quick-tweet/id505987287?mt=12 How can i make something like that circle? is that a
My app is a windows phone 7 application. In that i have created a
The app I'm working on is relatively simple but it is throwing memory warnings.
My app is placing a button with a custom background image and i doesn't
App Description: I have a UIWebview and a Toolbar beneath it. A button on
My app crashes, but generates no exception in the console and no crash log
The app in question is already localized into a few languages, but I'm adding

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.