• This repository has been archived on 05/Jan/2024
  • Stars
    star
    141
  • Rank 259,971 (Top 6 %)
  • Language
    Objective-C
  • License
    Apache License 2.0
  • Created about 12 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

#FWTPopoverView

FWTPopoverView screenshot

FWTPopoverView is a pretty flexible custom view for when you need a classic popover with a pointing arrow. The idea behind it was to create a very simple and basic API and make it easy to extend by accessing its custom objects/blocks entrypoints. FWTPopoverView is pure CG code, so no need to add assets and resolution independent for free.

##Requirements

  • XCode 4.4.1 or higher
  • iOS 5.0

##Features FWTPopoverView has few properties but uses several custom objects. If you want to adjust/change the appearance of the background, you change properties inside the background custom object; that also goes for animations and so on. On the other hand, if you're happy with the default style, all you need to do is set your contentSize and add your content to the contentView property.

There are two optional blocks that can be executed when the popover is presented/dismissed.

This project is not yet ARC-ready.

##Comparison with UIPopoverController

  • Block based API
  • Appearance/dismiss animations are easy to customise through animation blocks
  • Clean API to present/dismiss more than one popover either sequentially or all at once
  • No minimum size restrictions for the popover content
  • Works on the iPhone as well as on the iPad

##How to use it: initializing

Generally you don't initialize FWTPopoverView with a frame instead you set the contentSize and then call:

  • presentFromRect: inView: permittedArrowDirection: animated:

The default behaviour of the FWTPopoverView is to adjust its frame position to fit inside the superview bounds, when it falls on an intersection with the superview. You can change this by setting adjustPositionInSuperviewEnabled to NO.

##How to use it: configuration

####FWTPopoverBackgroundHelper This class needs a quick introduction: the popover image is a runtime image generated by a CAShapeLayer subclass. The layer is not directly added to the view hierarchy, instead is rendered in a separate context and the resulting image is used. The image is stretchable and takes up only a small chunk of memory. As with every CAShapeLayer you have access to all shape & style properties (clearly they're not animatable this time). The cornerRadius property is used as a property for the path.

  • drawPathBlock this block is executed just before return the image. It's a good point to customize or add more drawing stuff to your context
  • *(UIBezierPath )bezierPathForRect: returns the path for the current state/frame

####FWTPopoverAnimationHelper This class is a simple animation properties container.

####FWTPopoverArrow This class encapsulates some arrow specific properties.

  • direction (readonly) the direction in which the popover arrow is pointing
  • size the size of the arrow
  • offset (readonly) the distance (measured in points) from the center of the view to the center line of the arrow
  • cornerOffset the distance (measured in points) from the center of the arrow to the pointing edge of the arrow

##View hierarchy For a better understanding see the subviews/sublayers involved. Available public properties are in brackets.

  • popoverView {contentSize, adjustPositionInSuperviewEnabled}
    • backgroundImageView
    • contentView

##For your interest Future release of the backgroundHelper will include support for png images, as in UIPopoverBackgroundView.

##Demo The sample project shows how to use and how to create a custom FWTPopoverView. If you don't have time to read it this is what you need:

	//	present
	FWTPopoverView *popoverView = [[[FWTPopoverView alloc] init] autorelease];
	popoverView.contentSize = CGSizeMake(240, 140);
    [popoverView presentFromRect:rect
                          inView:self.view
         permittedArrowDirection:FWTPopoverArrowDirectionUp
                        animated:YES];
                        
    // …
    
    //	dismiss
    [popoverView dismissPopoverAnimated:YES];

##Licensing Apache License Version 2.0

##Credits Saudi Telecom Mobile Apps team, who enabled and collaborated with us to extract source code from My STC App for this library.

##Support, bugs and feature requests If you want to submit a feature request, please do so via the issue tracker on github. If you want to submit a bug report, please also do so via the issue tracker, including a diagnosis of the problem and a suggested fix (in code).