Thursday 15 July 2010

objective c - iOS programmatically alter uiview layout -


I have a page on my iOS app based on the following diagram, which is as follows.

  • Dark gray box = Navbar
  • Light gray box = UIView (for presentation, with some nice dropshadow etc.)
  • Black border = UIView (Again, with good shade,
  • 2 text fields
  • Pink box = Second view to display after an event.

    layout

    Currently, I'm laying everything with initWithFrame, and clear Establishing the frame of every item in the form which I'm probably not good at (I am new to the development of iOS, so please tell me in the right direction).

    What I am trying to achieve is that when some text is recorded in text 2 text area To reveal the pink box, and respond properly to the supervision, and layout well around the new field.

    I have no problem with this incident, and I just now Fold the frame of each UIView, but the point is Sector that it is wrong, and would love some pointers I would eventually like to animate the pink box, and I therefore consider that animate it with.

    I hope that I have fully explained myself a lot thanks

    If you want to trigger the event, then you have to run the closed animation behind it, then it is quite straightforward to do this

      - (zero) myEventMethod: (id) this {// Here's the event stuff // Animate the pink box in the visual // Below the Below the pink box is hidden behind the blackview and 0.3 delay: 0.0 option [UIView animateWithDuration is starting: It will be taken down 44px every time myEventMethod did not test // need not be careful - hopefully right - you want to drop it down to 44 pixels in 0.3 seconds UIViewAnimationOptionCurveEaseIn Animation: ^ {CGRect pinkboxEndFrame = CGRectMake ( Self.blackView.frame.origin.x, self.blackView.frame.origin.y + 44, self.pinkbox.frame.size.width, self.pinkbox.frame.size. Height); [Self. Pinbox Set Frame: PinkboxFrame]; } Completion: zero]; }   

    Just update the above with any other animation, which you want to do in other views.

    For more information about animating the scenes, you can see the apple from here.

  • No comments:

    Post a Comment