自定义UIAlertView iPhone [英] Custom UIAlertView iphone
本文介绍了自定义UIAlertView iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题..我使用了 http://kwigbo.com/post/318396305/iphone-sdk-custom-uialertview-background-color 创建我自己的自定义UIAlertView. 我不知道为什么,但是这行不通:
I have a problem .. I used this http://kwigbo.com/post/318396305/iphone-sdk-custom-uialertview-background-color to create my own custom UIAlertView. I do not know why but this will not work:
UILabel *theTitle = [theAlert valueForKey:@"_titleLabel"];
[theTitle setTextColor:[UIColor redColor]];
UILabel *theBody = [theAlert valueForKey:@"_bodyTextLabel"];
[theBody setTextColor:[UIColor blueColor]];
标题的颜色不变..texbody的颜色还可以.
the color of the title does not change .. the color of texbody it's ok.
- 如何自定义按钮?
推荐答案
使用自定义UIAleartView实现了同样的事情.
Hi Achieved same thing using custom UIAleartView.
-
按如下所示进行自定义视图.
Make a custom view as follows.
UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 5.0f, 262.0, 49)];
tempView.backgroundColor = [UIColor clearColor];
UILabel *lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(12, 0, 262.0, 49)];
lblTitle.font = [UIFont fontWithName:@"Arial" size:22.0f];
lblTitle.textColor = [UIColor whiteColor];
lblTitle.textAlignment = UITextAlignmentCenter;
lblTitle.text = @"Subscribe";
lblTitle.backgroundColor = [UIColor clearColor];
[tempView addSubview:lblTitle];
alreadySubscriber = [[UIButton alloc] initWithFrame:CGRectMake(12, 260, 262.0, 50)];
alreadySubscriber.layer.cornerRadius = 25.0f;
[alreadySubscriber setTitle:@"Already a subscriber" forState:UIControlStateNormal];
[alreadySubscriber setBackgroundImage:[UIImage imageNamed:@"BTN0.png"] forState:UIControlStateNormal];
[alreadySubscriber setBackgroundImage:[UIImage imageNamed:@"BTN1.png"] forState:UIControlStateSelected];
[tempView addSubview:alreadySubscriber];
将此内容插入UIAleartView
Insert this in UIAleartView
[self insertSubview:tempView atIndex:0];
[self setNeedsLayout];
->基本上,重要的是将UIAleartView的标题隐藏在标签后面.
-> basically matter is to hide UIAleartView's title behind a label.
这篇关于自定义UIAlertView iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文