• 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.}

     

  • 相关阅读:
    C#针对js escape解码
    .NET XML序列化与反序列化
    数据库文档生成工具(1)
    小欣外贸助手-国际站排名查询工具限量封测了
    七夕小福利
    利用正则表达式获取博客园随笔(四)
    利用正则表达式获取博客园随笔
    利用正则表达式获取博客园随笔(三)
    利用正则表达式获取博客园随笔(二)
    利用正则表达式获取博客园随笔(一)
  • 原文地址:https://www.cnblogs.com/wmwblog/p/5192915.html
Copyright © 2020-2023  润新知