iOS使用UIMenuController调用系统自带的复制、粘贴、剪切

来源:互联网 发布:java时间排序函数 编辑:程序博客网 时间:2024/05/16 07:14

使用UIMenuController,介绍如下:


// 只能用他的单例,单利构造方法是sharedMenuController。

#if UIKIT_DEFINE_AS_PROPERTIES
@property(class, nonatomic, readonly) UIMenuController *sharedMenuController;
#else
+ (UIMenuController *)sharedMenuController;

// 是否可见,默认是NO,即不可见

@property(nonatomic,getter=isMenuVisible) BOOL menuVisible;

// 设置弹出的位置

- (void)setTargetRect:(CGRect)targetRect inView:(UIView *)targetView;

// 箭头方向

@property(nonatomic) UIMenuControllerArrowDirection arrowDirection

// 让他弹出或者消失

- (void)setMenuVisible:(BOOL)menuVisible animated:(BOOL)animated;

// 添加自定义的东西,如果微信、QQ的“收藏”

@property(nullable, nonatomic,copy) NSArray<UIMenuItem *> *menuItems


//监听其弹出与消失的通知

UIMenuControllerWillShowMenuNotification
UIMenuControllerDidShowMenuNotification
UIMenuControllerWillHideMenuNotification
UIMenuControllerDidHideMenuNotification
UIMenuControllerMenuFrameDidChangeNotification


1 0
原创粉丝点击