简单好用可任意定制的iOS窗气泡效果

  

效果图如下所示:

  

简单好用可任意定制的iOS窗气泡效果”>,</p>
  <p>迅速:https://github.com/corin8823/Popover OC: https://github.com/Assuner-Lee/PopoverObjC <br/>
  </p>
  <p>使用示例</p>
  
  <pre类=   豆荚的PopoverObjC   #进口“ASViewController.h”   # import & lt; PopoverObjC/ASPopover.h>   @ interface ASViewController ()   @ property(弱,原子)IBOutlet UIButton * btn;   @ property(原子、强)ASPopover * btnPopover;   @ property(原子、强)ASPopover * itemPopover;   @end   @ implementation ASViewController   - (void) viewDidLoad {   (超级viewDidLoad);   (自我。btn addTarget:自我行动:@ selector (clickBtn:) forControlEvents: UIControlEventTouchUpInside];   self.navigationItem。rightBarButtonItem=[[UIBarButtonItem alloc] initWithTitle: @“物品”风格:UIBarButtonItemStylePlain目标:自我行动:@ selector (clickItem:)];   }   - (void) didReceiveMemoryWarning {   }      

初始化弹窗

        ——(ASPopover *) btnPopover {   如果(! _btnPopover) {   ASPopoverOption *选项=[[ASPopoverOption alloc] init);   选择。popoverType=ASPopoverTypeUp;   选择。autoAjustDirection=没有;   选择。arrowSize=CGSizeMake (9、6);   选择。blackOverlayColor=[用户界面颜色clearColor];   选择。popoverColor=[用户界面颜色lightGrayColor];   选择。dismissOnBlackOverlayTap=是的;   选择。animationIn=0.5;//?   _btnPopover=[[ASPopover alloc] initWithOption:选项];   }   返回_btnPopover;   }   ——(ASPopover *) itemPopover {   如果(! _itemPopover) {   ASPopoverOption *选项=[[ASPopoverOption alloc] init);   选择。autoAjustDirection=没有;   选择。arrowSize=CGSizeMake (10 6);   选择。blackOverlayColor=[用户界面颜色clearColor];   选择。sideEdge=7;   选择。dismissOnBlackOverlayTap=是的;   选择。popoverColor=[[用户界面颜色blackColor] colorWithAlphaComponent: 0.7);   选择。autoAjustDirection=是的;   选择。animationIn=0.4;   选择。springDamping=0.5;   选择。initialSpringVelocity=1;   选择。overlayBlur=[UIBlurEffect effectWithStyle UIBlurEffectStyleLight):;//?   _itemPopover=[[ASPopover alloc] initWithOption:选项];   }   返回_itemPopover;   }      

弹出窗口的属性可在选项里设置。

  

弹出气泡

        - (void) clickBtn:发送者(id) {   UIView *视图=[[UIView alloc] initWithFrame: CGRectMake (0, 0, [UIScreen mainScreen] .bounds.size。宽度- 50、40)];   (自我。btnPopover显示:查看fromView self.btn):;//在委托窗口中   }   - (void) clickItem:发送者(id) {   UIView *视图=[[UIView alloc] initWithFrame: CGRectMake (0, 0, 100, 200)];   (self.navigationItem UIView * itemView=ightBarButtonItem valueForKey: @“视图”);//你应该使用自定义视图项;   如果(itemView) {//(自我。itemPopover显示:查看fromView itemView):;   CGPoint originPoint=[自我。itemPopover originArrowPointWithView:查看fromView itemView):;   originPoint。y +=5;   (自我。itemPopover显示:查看atPoint originPoint):;   }   }   @end      

可在某一个视图或某一个点上弹出内容视图

        弹出窗口界面   # import & lt; UIKit/UIKit.h>   #进口“ASPopoverOption.h”   typedef无效(^ ASPopoverBlock)(空白);   @ interface ASPopover: UIView   @ property(原子、复制)ASPopoverBlock willShowHandler;   @ property(原子、复制)ASPopoverBlock willDismissHandler;   @ property(原子、复制)ASPopoverBlock didShowHandler;   @ property(原子、复制)ASPopoverBlock didDismissHandler;   @ property(原子、强)ASPopoverOption *选项;   - (instancetype) initWithOption:(ASPopoverOption *)选择;   - (void)驳回;   - (void)显示:(UIView *) contentView fromView: fromView (UIView *);   - (void)显示:(UIView *) contentView fromView: (UIView *) fromView针对我国有关矿山截污库坝:针对我国有关矿山截污库坝(UIView *);   - (void)显示:(UIView *) contentView atPoint: (CGPoint)点;   - (void)显示:(UIView *) contentView atPoint: (CGPoint)针对我国有关矿山截污库坝:针对我国有关矿山截污库坝(UIView *);   ——(CGPoint) originArrowPointWithView:(UIView *) contentView fromView: fromView (UIView *);   ——(CGPoint) arrowPointWithView:(UIView *) contentView fromView: (UIView *) fromView针对我国有关矿山截污库坝:(UIView *)针对我国有关矿山截污库坝popoverType: (ASPopoverType)类型;   @end

简单好用可任意定制的iOS窗气泡效果