开发者

How do they do that?... avoiding a boring, standard cookie-cutter iPhone app

I am trying to figure out the best design for a custom floating "pallet" for initiating actions (e.g., change sorting criteria of a list) as well as switching views (e.g., Help, Options). I want the pallet to start out collapsed so the initial view is full-screen. When the user touches the corner of the screen the view slides into place with animation. Another touch slides the view out of the way.

The best example of the UI I am going for is one of my favorite apps, the iThoughts mind mapper (see below). How is this done? I really want to learn how the pros create such beautiful apps. Most of the help I find points me in the direction of t开发者_开发问答he standard UITabbar, UIToolbar, etc. Yawn.

Thanks!

How do they do that?... avoiding a boring, standard cookie-cutter iPhone app

How do they do that?... avoiding a boring, standard cookie-cutter iPhone app


You should start off by learning how to do it the conventional way. Make the app work first. Then expand on it. When you fully master the conventional method, learn Core Animation and how to use layers.


Assumptions:

  • You want to animate a view called toolbar.
  • You have stored the frame coordinates for the toolbar view for its offscreen state in a CGRect toolbarFrameWhenHidden property. Correspondingly, CGRect toolbarFrameWhenShown contains the frame coordinates for the displayed state.
  • You have a BOOL toolbarHidden property that indicates the current state of the toolbar.
  • You have connected the control that the user should tap to show/hide the toolbar to the toggleToolbar: action.

The code:

- (IBAction) toggleToolbar:(id)sender
{
    CGRect targetFrame = self.toolbarHidden ? self.toolbarFrameWhenShown : self.toolbarFrameWhenHidden;
    [UIView animateWithDuration:0.25 animations:^{
        self.toolbar.frame = targetFrame;
    }];
    self.toolbarHidden = !self.toolbarHidden;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜