настраиваемый цвет оповещения и увеличение его рамки в зависимости от ввода текста - PullRequest
0 голосов
/ 19 сентября 2011

Я добавляю настраиваемое представление оповещений и хочу изменить его цвет на желтый с текстовым представлением. Для этого есть свойство, в которое мы передаем имя прозрачного изображения этого цвета, и оповещение выбирает этот цвет. ТакжеЯ хочу, чтобы размер оповещения динамически увеличивался в зависимости от текста в текстовом представлении. Любая помощь будет принята с благодарностью

Спасибо Vikas

Ответы [ 2 ]

0 голосов
/ 14 июня 2013
you can use this code to customize your uialertview..
You can take out the subviews of uialertview and can customize it any way you want.
Here is the code I used to customize the uialertivew
==========



-(void)willPresentAlertView:(UIAlertView *)alertView{
    for(UIView *view in alertView.subviews){
        view.backgroundColor= [UIColor clearColor];
    }
    UILabel *title = [alertView valueForKey:@"_titleLabel"];
    title.font = [UIFont fontWithName:@"Gibson-Regular" size:15.0];
    [title setTextColor:[UIColor whiteColor]];// set title color and font

    UILabel *body = [alertView valueForKey:@"_bodyTextLabel"];
    body.font = [UIFont fontWithName:@"Gibson-Regular" size:15.0];
    [body setTextColor:[UIColor whiteColor]];//set body color and font

    //after giving 12345 tag to your alert
    UITextView *txtBody=(UITextView*)[alertView viewWithTag:12345];
    if(txtBody){//scrollable
        txtBody.scrollEnabled = NO;
        CGRect frame  = txtBody.frame;
        frame.origin = CGPointMake(0, 0);
        UITextView *txtView = [[UITextView alloc]initWithFrame:frame];
        txtView.editable = NO;
        txtView.text = txtBody.text;
        txtView.font = [UIFont fontWithName:@"Gibson-Regular" size:15.0];
        [txtView setTextColor:[UIColor whiteColor]];
        [txtBody addSubview:txtView];
        txtBody.text=@"";

    }
    NSLog(@"%@",txtBody.subviews);
    for(UIView *view in txtBody.subviews){
        view.backgroundColor= [UIColor clearColor];
    }

    //    alertView.backgroundColor=[UIColor redColor];
}
0 голосов
/ 21 сентября 2011

изменил цвет с кодом ниже. Но как отключить предупреждение

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlert View" message:@"hello" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Close",nil];

UIImage *alertImage = [UIImage imageNamed:@"plus.png"];

UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:alertImage];

backgroundImageView.frame = CGRectMake(0, 0, 282, 130);

backgroundImageView.contentMode = UIViewContentModeScaleToFill;

[alert addSubview:backgroundImageView];

[alert sendSubviewToBack:backgroundImageView]; 
[alert show];
[alert release];
...