自定义UIAlertView

来源:互联网 发布:effective java中文版 编辑:程序博客网 时间:2024/05/22 00:27

- (void)viewDidLoad {
    [super viewDidLoad];
/*
    UIAlertView *alertView = [[UIAlertView alloc]
                              initWithTitle:NSLocalizedString(@"", nil)
                              message:NSLocalizedString(@"\n\n\n", nil)
                              delegate:self
                              cancelButtonTitle:@"注册"
                              otherButtonTitles:@"登陆",
                              nil];

//用户名
    UILabel *user_name = [[UILabel alloc] initWithFrame:CGRectMake( 20, 25, 60, 25)];
    [user_name setBackgroundColor:[UIColor clearColor]];
    user_name.lineBreakMode = UILineBreakModeWordWrap;
    //user_name.numberOfLines = 0;
    [user_name setTextColor:[UIColor whiteColor]];
    [user_name setFont:[UIFont systemFontOfSize:15.0]];
    user_name.text = @"用户名";
    [alertView addSubview:user_name];
    [user_name release];
    
    UITextField *name = [[UITextField alloc] initWithFrame:CGRectMake( 80, 25, 180, 25)];
    [name setBackgroundColor:[UIColor clearColor]];
    [name setBorderStyle:UITextBorderStyleBezel];
    name.backgroundColor = [UIColor whiteColor];
    name.placeholder = @"User name";
    [alertView addSubview:name];
    [name release];
//user pass_word
    UILabel *pass_word = [[UILabel alloc] initWithFrame:CGRectMake(20, 60, 40,25)];
    [pass_word setBackgroundColor:[UIColor clearColor]];
    pass_word.lineBreakMode = UILineBreakModeWordWrap;
    //pass_word.numberOfLines = 1
    [pass_word setTextColor:[UIColor whiteColor]];
    [pass_word setFont:[UIFont systemFontOfSize:15.0]];
    pass_word.text = @"密  码";
    [alertView addSubview:pass_word];
    [pass_word release];

    UITextField *passwordText = [[UITextField alloc] initWithFrame:CGRectMake( 80, 60, 180, 25)];
    [passwordText setSecureTextEntry:YES];
    [passwordText setBackgroundColor:[UIColor clearColor]];
    [passwordText setBorderStyle:UITextBorderStyleBezel];
    passwordText.backgroundColor = [UIColor whiteColor];
    passwordText.placeholder = @"pass_word";
    [alertView addSubview:passwordText];
    [passwordText release];
//buttons
    for (UIView *Outlet in [alertView subviews])
    {
        if(![Outlet isKindOfClass:[UITextField class]]&&![Outlet isKindOfClass:[UILabel class]])
        {
            UIButton* button = (UIButton*)Outlet;
            button.frame = CGRectMake(button.frame.origin.x,100,button.frame.size.width , button.frame.size.height);
        }
    }
    [alertView setTransform:CGAffineTransformMakeTranslation(0, -60)];
    [alertView show];
    [alertView release];
 */
}

原创粉丝点击