1

I had develop a instant meaning checker like one in UIMENU Button,it working fine but since i had used the alert method to show the meaning,the appearnce of the alert is not good.can any one tell me how to get the appearance of that of the define method in UIMENU button

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

This is the code and the alert view that i got isWith the alert view of custom uimenu buttonWith  the define function of the UIMENU button

1 Answers1

0

I'm assuming that you are using tap gesture to show the menu. The following code displays a UIMenu of 100x100 with title as "Custom Action"

- (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];

}

For a detailed version, have a look here.

Sagar D
  • 2,588
  • 1
  • 18
  • 31