Search code examples
iphoneviewibooks

How was this 'pop-up' view created?


Please see the image below.

How was this 'pop-up' view created? Suppose I wanted to completely imitate that view with the fonts, how would I do so?

enter image description here


Solution

  • There is not a SDK exposed component for this, but this could very easily be made using a hierarchy of views:

    UIView - Main view. Uses a bezier path to create a protrusion to point from the source. Has a border and drop shadow added to its layer.

    UIButton - Smaller font
    UIButton - Larger font
    UIButton - Change font type
    UIButton - Container for sepia.
    UILabel - "Sepia" text UISwitch - turning sepia on and off

    Just show and hide the view with an animation. Also, create delegate callbacks to tell the delegate when events occur in the popover.

    // Delegate returns if the text can get smaller to enable/disable the button
    - (BOOL) didSelectSmallerFont:(CGFloat)fontSize;
    // Delegate returns if the text can get larger to enable/disable the button
    - (BOOL) didSelectLargerFont:(CGFloat)fontSize; 
    - (void) didChangeFont:(UIFont*)font;
    - (void) didToggleSepia:(BOOL)enabled;
    

    etc.