91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

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

發布時間:2020-08-23 17:40:16 來源:腳本之家 閱讀:872 作者:Assuner 欄目:移動開發

效果圖如下所示:

簡單好用可任意定制的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里設置。

彈出氣泡

- (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

可在某一個視圖或某一個point上彈出內容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: 要顯示的內容; fromView: 氣泡從某一個視圖上show; inview: 氣泡繪制在某一個視圖上,一般為delegate window; atPoint: 氣泡從某一點上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

總結

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

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

清丰县| 怀来县| 平原县| 双峰县| 昌宁县| 县级市| 思茅市| 综艺| 忻州市| 宣威市| 法库县| 塔河县| 杨浦区| 迭部县| 高尔夫| 元江| 法库县| 兴仁县| 达日县| 将乐县| 绵竹市| 都兰县| 孟连| 正定县| 吴旗县| 雷山县| 枞阳县| 海林市| 黔西| 神农架林区| 青州市| 涟水县| 兴隆县| 延长县| 临漳县| 林周县| 朔州市| 杂多县| 双鸭山市| 堆龙德庆县| 兴海县|