“AFInformationView” Bubbles on the iPhone

My iPhone application, Presenter, lets the user choose whether they want to swipe, tap, or use buttons to change slides. The Settings panel contains a 3 button segmented control to customize this behavior on the fly. Instead of including a help screen or inserting a large UILabel underneath the segmented control, I wrote a class that displays a floating UILabel on top of each button when selected.

AFInformationView in action

Calling this helper class is very simple. Pass in the target view, location, label text and a few other parameters.

- (void)displayInView:(UIView *)theView withText:(NSString *)displayText atLocation:(CGPoint)location width:(CGFloat)width isTriangleOnTop:(Boolean)isTriangleOnTop triangleHorizontalLocation:(CGFloat)triangleHorizontalLocation forDuration:(NSTimeInterval)duration;

AFInformationView will fade in a multi-line, semi-transparent, black label with rounded corners & a target triangle. The label’s text will wrap and grow vertically, depending on its width. After a specified amount of time, the label again fades out. If the user taps on the label, it fades out immediately.

I have included a sample Xcode project demonstrating its use.

http://fajkowski.com/code/AFInformationView/AFInformationView.zip

Click here to see a short video of the Xcode project in use.

I have released the code with an MIT license. Feel free to reuse it in any project you’d like.


About this entry