1

我已经开发了一个即时含义检查器,例如 UIMENU Button 中的一个,它工作正常,但是由于我使用了警报方法来显示含义,所以警报的外观不好。谁能告诉我如何获得它的外观UIMENU 按钮中的定义方法

UIAlertView *av = [[UIAlertView alloc] initWithFrame:CGRectMake(0,0,300,200)];//[[UIAlertView alloc] initWithTitle:newstring message:nil delegate:nil cancelButtonTitle:@"ཕྱིར་འཐེན།" otherButtonTitles:nil];
    av.title = newstring;
    av.layer.backgroundColor=(__bridge CGColorRef)([UIColor colorWithRed:22/255.0f green:113/225.0f blue:9/255.0f alpha:1.0f]);
    av.message = nil;
    av.delegate = nil ;
    [av addButtonWithTitle:@"ཕྱིར་འཐེན།"];
    //[av addButtonWithTitle:@"OK"];
    UITextView *v = [[UITextView alloc] initWithFrame:CGRectMake(0,0,300,200)];      //av.bounds];
    v.text=newstring1;
    [v setEditable:NO];
    v.font=[UIFont fontWithName:@"Monlam Uni OuChan2" size:19];
    [av setValue:v forKey:@"accessoryView"];
    v.backgroundColor = [UIColor yellowColor];
    [av show];

这是我得到的代码和警报视图带有自定义 uimenu 按钮的警报视图带有 UIMENU 按钮的定义功能

4

1 回答 1

0

我假设您正在使用点击手势来显示菜单。以下代码显示 100x100 的 UIMenu,标题为“自定义操作”

- (void)handleTapGesture:(UITapGestureRecognizer *)tapGesture {
    NSLog(@"tapGesture:");
//    CGRect targetRectangle = self.tapView.frame;
    CGRect targetRectangle = CGRectMake(100, 100, 100, 100);
    [[UIMenuController sharedMenuController] setTargetRect:targetRectangle
                                                    inView:self.view];

    UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:@"Custom Action"
                                                  action:@selector(customAction:)];

    [[UIMenuController sharedMenuController]
     setMenuItems:@[menuItem]];
    [[UIMenuController sharedMenuController]
     setMenuVisible:YES animated:YES];

}

有关详细版本,请查看此处

于 2015-11-04T11:20:03.873 回答