Skip to content

Latest commit

 

History

History
147 lines (103 loc) · 5.42 KB

README.rst

File metadata and controls

147 lines (103 loc) · 5.42 KB

CMPopTipView

An iOS UIView subclass that displays a rounded rect "bubble", containing a text message, pointing at a specified button or view.

A CMPopTipView will automatically position itself within the view so that it is pointing at the specified button or view, positioning the "pointer" as necessary.

A CMPopTipView can be pointed at any UIView within the containing view. It can also be pointed at a UIBarButtonItem within either a UINavigationBar or a UIToolbar and it will automatically position itself to point at the target.

The background and text colors can be customised if the defaults are not suitable.

Two animation options are available for when a CMPopTipView is presented: "slide" and "pop".

A CMPopTipView can be dismissed by the user tapping on it. It can also be dismissed programatically.

CMPopTipView is rendered entirely by Core Graphics.

The source includes a universal (iPhone/iPad) demo app.

URLs

Used in apps:

Screenshots

iphone_demo_1 iphone_demo_2 ipad_demo_1

Videos

http://www.youtube.com/watch?v=nul9VA_QsGI

Usage

Example 1 - point at a UIBarButtonItem in a nav bar:

// Present a CMPopTipView pointing at a UIBarButtonItem in the nav bar
CMPopTipView *navBarLeftButtonPopTipView = [[[CMPopTipView alloc] initWithMessage:@"A Message"] autorelease];
navBarLeftButtonPopTipView.delegate = self;
[navBarLeftButtonPopTipView presentPointingAtBarButtonItem:self.navigationItem.leftBarButtonItem animated:YES];

// Dismiss a CMPopTipView
[navBarLeftButtonPopTipView dismissAnimated:YES];

// CMPopTipViewDelegate method
- (void)popTipViewWasDismissedByUser:(CMPopTipView *)popTipView {
  // Any cleanup code, such as releasing a CMPopTipView instance variable, if necessary
}

Example 2 - pointing at a UIButton, with custom color scheme:

- (IBAction)buttonAction:(id)sender {
  // Toggle popTipView when a standard UIButton is pressed
  if (nil == self.roundRectButtonPopTipView) {
    self.roundRectButtonPopTipView = [[[CMPopTipView alloc] initWithMessage:@"My message"] autorelease];
    self.roundRectButtonPopTipView.delegate = self;
    self.roundRectButtonPopTipView.backgroundColor = [UIColor lightGrayColor];
    self.roundRectButtonPopTipView.textColor = [UIColor darkTextColor];

    UIButton *button = (UIButton *)sender;
    [self.roundRectButtonPopTipView presentPointingAtView:button inView:self.view animated:YES];
  }
  else {
    // Dismiss
    [self.roundRectButtonPopTipView dismissAnimated:YES];
    self.roundRectButtonPopTipView = nil;
  }
}

#pragma mark CMPopTipViewDelegate methods
- (void)popTipViewWasDismissedByUser:(CMPopTipView *)popTipView {
  // User can tap CMPopTipView to dismiss it
  self.roundRectButtonPopTipView = nil;
}

ARC

The CMPopTipView Master branch is non-ARC. However, producing an ARC version is easy as CMPopTipView memory management is kept clean and ARC-conversion ready.

To generate an ARC version simply open the demo app project in Xcode and select: Edit / Refactor / Convert to Objective-C ARC... The project should convert cleanly and the ARC-ready CMPopTipView source can then be copied to your project. If any ARC problems, please raise an issue.

Support

CMPopTipView is provided open source with no warranty and no guarantee of support. However, best effort is made to address issues raised on Github https://github.com/chrismiles/CMPopTipView/issues .

If you would like assistance with integrating CMPopTipView or modifying it for your needs, contact the author Chris Miles <[email protected]> for consulting opportunities.

License

CMPopTipView is Copyright (c) 2010-2012 Chris Miles and released open source under a MIT license:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.