【问题标题】:how to customized the define function in ios如何在ios中自定义define函数
【发布时间】:2016-02-04 12:03:55
【问题描述】:

我在 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];

这是我得到的代码和警报视图是

【问题讨论】:

  • 各位有什么办法可以解决这个问题的......

标签: ios customization uimenuitem


【解决方案1】:

我假设您正在使用点击手势来显示菜单。 以下代码显示 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];

}

详细版本请看here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多