UIAlertview改变按钮位置 大小

时间:2022-02-19 10:20:53
//versionAlertView最好设为全局
versionAlertView = [[UIAlertView alloc] initWithTitle:@"标题" message:@"One Style\nOne Style\nOne Style\nOne Style\nOne Style\nOne Style\nOne Style\nOne Style\nOne Style\nOne Style\nOne Style\nOne Style\nOne Style" delegate:self cancelButtonTitle:@"cancle" otherButtonTitles:@"One", @"two", nil];
    [versionAlertView show];
    [versionAlertView release];


//这里可以改变
- (void)willPresentAlertView:(UIAlertView *)alertView
{
   
    UIButton * cancelButton = (UIButton *)[alertView viewWithTag:1];
    [cancelButton setFrame:CGRectMake(19, versionAlertView.bounds.size.height - 60, 70, 40)];
    //CGRectMake(cancelButton.frame.origin.x, 100, cancelButton.frame.size.width, cancelButton.frame.size.height);
    UIButton * oneButton = (UIButton *)[alertView viewWithTag:2];
    [oneButton setFrame:CGRectMake(18+19+70, versionAlertView.bounds.size.height - 60, 70, 40)];
    
    UIButton * twoButton = (UIButton *)[alertView viewWithTag:3];
    [twoButton setFrame:CGRectMake(70+70+18+18+20, versionAlertView.bounds.size.height - 60, 70, 40)];
    
   
}


//记得设置代理