Skip to content
ObjC version of Popover
Objective-C Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
PopoverObjC
.gitignore
.travis.yml
LICENSE
PopoverObjC.podspec
README.md
_Pods.xcodeproj

README.md

Objc version of Popover (https://github.com/corin8823/Popover)

CI Status Version License Platform

Example

exmple
#import "ASViewController.h"
#import <PopoverObjC/ASPopover.h>

@interface ASViewController ()

@property (weak, nonatomic) IBOutlet UIButton *btn;
@property (nonatomic, strong) ASPopover *btnPopover;
@property (nonatomic, strong) ASPopover *itemPopover;

@end

@implementation ASViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  [self.btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];

  self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"item" style:UIBarButtonItemStylePlain target:self action:@selector(clickItem:)];
}

- (void)didReceiveMemoryWarning {
}

- (ASPopover *)btnPopover {
  if (!_btnPopover) {
    ASPopoverOption *option = [[ASPopoverOption alloc] init];
    option.autoAjustDirection = YES;
    option.preferedType = ASPopoverTypeDown; // set prefered derection when autoAjustDirection = YES;
    option.arrowSize = CGSizeMake(9, 6);
    option.blackOverlayColor = [UIColor clearColor];
    option.popoverColor = [UIColor lightGrayColor];
    option.dismissOnBlackOverlayTap = YES;
    option.animationIn = 0.5;
    //...

  _btnPopover = [[ASPopover alloc] initWithOption:option];
  }
  return _btnPopover;
}


- (ASPopover *)itemPopover {
if (!_itemPopover) {
ASPopoverOption *option = [[ASPopoverOption alloc] init];
option.autoAjustDirection = YES;
option.arrowSize = CGSizeMake(10, 6);
option.offset = 3;  // vertical offset from original show point, default is 0.
option.blackOverlayColor = [UIColor clearColor];
option.sideEdge = 7;
option.dismissOnBlackOverlayTap = YES;
option.popoverColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
option.animationIn = 0.4;
option.springDamping = 0.5;
option.initialSpringVelocity = 1;
option.overlayBlur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
//...

_itemPopover = [[ASPopover alloc] initWithOption:option];
}
return _itemPopover;
}

- (void)clickBtn:(id)sender {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width - 50, 40)];
[self.btnPopover show:view fromView:self.btn];  // in delegate window
}

- (void)clickItem:(id)sender {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)];
UIView *itemView = [self.navigationItem.rightBarButtonItem valueForKey:@"view"]; // you should use custom view in item;
if (itemView) {
[self.itemPopover show:view fromView:itemView]; // above, option has contained offset value; invoke [self show:contentView fromView:fromView inView:keyWindow];

/* other method to show

CGPoint orignPoint = [self.itemPopover orignArrowPointWithView:view fromView:itemView];
orignPoint.y += 5; // offset in option has same effect
[self.itemPopover show:view atPoint:orignPoint];

*/
}
@end

Requirements

Installation

PopoverObjC is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PopoverObjC'

Author

Assuner-Lee, assuner@foxmail.com

License

PopoverObjC is available under the MIT license. See the LICENSE file for more info.

You can’t perform that action at this time.