zoukankan      html  css  js  c++  java
  • UIMenuController

    实现代码如下:

    01.-(IBAction)panGestureTop:(UILongPressGestureRecognizer *)longPress
    02.{
    03. 
    04.UIMenuItem * itemPase = [[UIMenuItem alloc] initWithTitle:@"复制" action:@selector(copyimage)];
    05.UIMenuItem * itemTrans = [[UIMenuItem alloc] initWithTitle:@"转发" action:@selector(trans)];
    06.UIMenuItem * itemCollect = [[UIMenuItem alloc] initWithTitle:@"收藏" action:@selector(collect)];
    07.UIMenuItem * itemJoin = [[UIMenuItem alloc] initWithTitle:@"加入" action:@selector(join)];
    08. 
    09.UIMenuController * menuController = [UIMenuController sharedMenuController];
    10.[menuController setMenuItems: @[itemPase,itemCollect,itemTrans,itemJoin]];
    11. 
    12.CGPoint location = [longPress locationInView:[longPress view]];
    13.CGRect menuLocation = CGRectMake(location.x, location.y, 00);
    14.[menuController setTargetRect:menuLocation inView:[longPress view]];
    15.menuController.arrowDirection = UIMenuControllerArrowDown;
    16. 
    17.[menuController setMenuVisible:YES animated:YES];
    18. 
    19.}
    20.-(BOOL)canBecomeFirstResponder
    21.{
    22.return YES;
    23.}
    24. 
    25.-(void)copyimage
    26.{
    27. 
    28.UIPasteboard * pasterBoard = [UIPasteboard pasteboardWithName:@"com.test.image" create:YES];
    29.pasterBoard.image = [self.topImgView image];
    30. 
    31.}
    32.-(IBAction)panGestureBottom:(UILongPressGestureRecognizer *)longPress
    33.{
    34.UIMenuItem * itemPase = [[UIMenuItem alloc] initWithTitle:@"粘贴" action:@selector(pase)];
    35. 
    36.UIMenuController * menuController = [UIMenuController sharedMenuController];
    37.[menuController setMenuItems: @[itemPase]];
    38. 
    39.CGPoint location = [longPress locationInView:[longPress view]];
    40.CGRect menuLocation = CGRectMake(location.x, location.y, 00);
    41.[menuController setTargetRect:menuLocation inView:[longPress view]];
    42.menuController.arrowDirection = UIMenuControllerArrowDown;
    43. 
    44.[menuController setMenuVisible:YES animated:YES];
    45. 
    46.}
    47.-(void)pase
    48.{
    49.UIPasteboard * pasterBoard = [UIPasteboard pasteboardWithName:@"com.test.image" create:NO];
    50.self.bottomImgView.image = pasterBoard.image;
    51. 
    52.}

     

  • 相关阅读:
    Vue父子组件传值之——访问根组件$root、$parent、$children和$refs
    js判断是否为ie浏览器,精确显示各个ie版本
    在JS/jQuery中,怎么触发input的keypress/keydown/keyup事件?
    HTML中a标签自动识别电话、邮箱
    如何彻底删除Mac磁盘中的文件
    使用Understand for Mac编写您的第一个API脚本
    如何将MacOS Catalina降级为Mojave
    macOS Catalina 10.15.1 发布 全新 Emoji、支持 AirPods Pro
    WingIDE Pro 7如何新建项目
    忘记MacBook密码的解决技巧!
  • 原文地址:https://www.cnblogs.com/wmwblog/p/5192915.html
Copyright © 2011-2022 走看看