iOS使用UIMenuController调用系统自带的复制、粘贴、剪切
使用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

浙公网安备 33010602011771号