欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

簡單好用可任意定制的iOS Popover氣泡效果

 更新時(shí)間:2017年12月22日 11:46:54   作者:Assuner  
Popover(氣泡彈出框/彈出式氣泡/氣泡)是由一個(gè)矩形和三角箭頭組成的彈出窗口,箭頭指向的地方通常是導(dǎo)致Popover彈出的控件或區(qū)域。本文通過實(shí)例代碼給大家介紹了iOS Popover氣泡效果,需要的朋友參考下吧

效果圖如下所示:

 

swift: https://github.com/corin8823/Popover OC: https://github.com/Assuner-Lee/PopoverObjC

使用示例

pod 'PopoverObjC'
#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 {
}

初始化Popover

- (ASPopover *)btnPopover {
 if (!_btnPopover) {
 ASPopoverOption *option = [[ASPopoverOption alloc] init];
 option.popoverType = ASPopoverTypeUp;
 option.autoAjustDirection = NO;
 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 = NO;
 option.arrowSize = CGSizeMake(10, 6);
 option.blackOverlayColor = [UIColor clearColor];
 option.sideEdge = 7;
 option.dismissOnBlackOverlayTap = YES;
 option.popoverColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
 option.autoAjustDirection = YES;
 option.animationIn = 0.4;
 option.springDamping = 0.5;
 option.initialSpringVelocity = 1;
 option.overlayBlur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
 //...
 _itemPopover = [[ASPopover alloc] initWithOption:option];
 }
 return _itemPopover;
}

popover的屬性可在option里設(shè)置。

彈出氣泡

- (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];
 CGPoint originPoint = [self.itemPopover originArrowPointWithView:view fromView:itemView];
 originPoint.y += 5;
 [self.itemPopover show:view atPoint:originPoint];
 }
}
@end

可在某一個(gè)視圖或某一個(gè)point上彈出內(nèi)容view

Popover interface
#import <UIKit/UIKit.h>
#import "ASPopoverOption.h"
typedef void (^ASPopoverBlock)(void);
@interface ASPopover : UIView
@property (nonatomic, copy) ASPopoverBlock willShowHandler;
@property (nonatomic, copy) ASPopoverBlock willDismissHandler;
@property (nonatomic, copy) ASPopoverBlock didShowHandler;
@property (nonatomic, copy) ASPopoverBlock didDismissHandler;
@property (nonatomic, strong) ASPopoverOption *option;
- (instancetype)initWithOption:(ASPopoverOption *)option;
- (void)dismiss;
- (void)show:(UIView *)contentView fromView:(UIView *)fromView;
- (void)show:(UIView *)contentView fromView:(UIView *)fromView inView:(UIView *)inView;
- (void)show:(UIView *)contentView atPoint:(CGPoint)point;
- (void)show:(UIView *)contentView atPoint:(CGPoint)point inView:(UIView *)inView;
- (CGPoint)originArrowPointWithView:(UIView *)contentView fromView:(UIView *)fromView;
- (CGPoint)arrowPointWithView:(UIView *)contentView fromView:(UIView *)fromView inView:(UIView *)inView popoverType:(ASPopoverType)type;
@end

contentView: 要顯示的內(nèi)容; fromView: 氣泡從某一個(gè)視圖上show; inview: 氣泡繪制在某一個(gè)視圖上,一般為delegate window; atPoint: 氣泡從某一點(diǎn)上show; 可先獲取originPoint, 偏移;

PopoverOption Interface
typedef NS_ENUM(NSInteger, ASPopoverType) {
 ASPopoverTypeUp = 0,
 ASPopoverTypeDown,
};
@interface ASPopoverOption : NSObject
@property (nonatomic, assign) CGSize arrowSize;
@property (nonatomic, assign) NSTimeInterval animationIn; // if 0, no animation
@property (nonatomic, assign) NSTimeInterval animationOut;
@property (nonatomic, assign) CGFloat cornerRadius;
@property (nonatomic, assign) CGFloat sideEdge;
@property (nonatomic, strong) UIColor *blackOverlayColor;
@property (nonatomic, strong) UIBlurEffect *overlayBlur;
@property (nonatomic, strong) UIColor *popoverColor;
@property (nonatomic, assign) BOOL dismissOnBlackOverlayTap;
@property (nonatomic, assign) BOOL showBlackOverlay;
@property (nonatomic, assign) CGFloat springDamping;
@property (nonatomic, assign) CGFloat initialSpringVelocity;
@property (nonatomic, assign) ASPopoverType popoverType;
@property (nonatomic, assign) BOOL highlightFromView;
@property (nonatomic, assign) CGFloat highlightCornerRadius;
@property (nonatomic, assign) BOOL autoAjustDirection; // down preferred, effect just in view not at point
@end

總結(jié)

以上所述是小編給大家介紹的簡單好用可任意定制的iOS Popover氣泡效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家的支持!

相關(guān)文章

  • 禁止iPhone Safari video標(biāo)簽視頻自動(dòng)全屏的辦法

    禁止iPhone Safari video標(biāo)簽視頻自動(dòng)全屏的辦法

    本篇文章給大家分析有沒有辦法禁止iPhone Safari video標(biāo)簽視頻自動(dòng)全屏,以下給出好多種情況分享,感興趣的朋友可以參考下
    2015-09-09
  • iOS自定義圓形進(jìn)度提示控件

    iOS自定義圓形進(jìn)度提示控件

    這篇文章主要為大家詳細(xì)介紹了iOS自定義圓形進(jìn)度提示控件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-06-06
  • 詳談iPhoneX截圖如何帶

    詳談iPhoneX截圖如何帶

    下面小編就為大家分享一篇詳談iPhoneX截圖如何帶"劉海"和圓角,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • iOS10適配之權(quán)限Crash問題的完美解決方案

    iOS10適配之權(quán)限Crash問題的完美解決方案

    這篇文章主要為大家詳細(xì)介紹了iOS10適配之權(quán)限Crash問題的完美解決方案,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • iOS中的集合該如何弱引用對象示例詳解

    iOS中的集合該如何弱引用對象示例詳解

    這篇文章主要給大家介紹了關(guān)于在iOS中的集合該如何弱引用對象的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來依稀學(xué)習(xí)學(xué)習(xí)吧。
    2017-09-09
  • IOS 實(shí)現(xiàn)搖一搖的操作

    IOS 實(shí)現(xiàn)搖一搖的操作

    這篇文章主要介紹了IOS 實(shí)現(xiàn)搖一搖的操作的相關(guān)資料,需要的朋友可以參考下
    2016-10-10
  • iOS中使用JSPatch框架使Objective-C與JavaScript代碼交互

    iOS中使用JSPatch框架使Objective-C與JavaScript代碼交互

    有了JSPatch,我們便可以在iOS App開發(fā)中令JavaScript代碼調(diào)用原生的Objective-C屬性和方法等,下面就來詳細(xì)看一下如何在iOS中使用JSPatch框架使Objective-C與JavaScript代碼交互
    2016-06-06
  • Objective-C的MKNetworkKit開發(fā)框架解析

    Objective-C的MKNetworkKit開發(fā)框架解析

    這篇文章主要介紹了Objective-C的MKNetworkKit開發(fā)框架解析,MKNetworkKit是一個(gè)用于iOS開發(fā)的輕量級框架,需要的朋友可以參考下
    2015-11-11
  • iOS Runtime詳解(新手也看得懂)

    iOS Runtime詳解(新手也看得懂)

    這篇文章主要給大家介紹了關(guān)于iOS Runtime的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-02-02
  • ios中Deep Linking實(shí)例分析用法

    ios中Deep Linking實(shí)例分析用法

    本篇文章給大家分享了在IOS中Deep Linking的用法以及代碼實(shí)例,有興趣的朋友跟著學(xué)習(xí)下吧。
    2018-01-01

最新評論