自定义背景颜色的设置
来源:互联网 发布:零基础学c语言看什么书 编辑:程序博客网 时间:2024/04/30 07:36
#define kDEFAULT_DATE_TIME_FORMAT (@"yyyy-MM-dd")
-(void)buildLayout{
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(100, 30,150, 40)];
label.text=@"设置背景颜色";
label.backgroundColor=[UIColor clearColor];
[self.view addSubview:label];
[label release];
UISlider *slider=[[UISlider alloc]initWithFrame:CGRectMake(30,80, 250, 30)];
[slider addTarget:self action:@selector(colorchange:)forControlEvents:UIControlEventValueChanged];
slider.minimumValue=50;
slider.maximumValue=255;
slider.value=128;
slider.tag=100;
[self.view addSubview:slider];
[slider release];
UIButton *but=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];
but.frame=CGRectMake(100, 130, 100, 30);
[but setTitle:@"重置" forState:UIControlStateNormal];
[but addTarget:self action:@selector(btnclick)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:but];
-(void)colorchange:(id)sender{
UISlider *slider=sender;
UIColor *color=[UIColor colorWithRed:slider.value/20green:slider.value/100 blue:slider.value/300 alpha:1.0];
self.view.backgroundColor=color;
[[NSNotificationCenterdefaultCenter]postNotificationName:@"bgcolor" object:[UIColorcolorWithRed:slider.value/20 green:slider.value/100blue:slider.value/300 alpha:1.0]];
}
-(void)changebg:(NSNotification *)bg{
AppDelegate *nowdelegate=[UIApplicationsharedApplication].delegate;
nowdelegate.window.backgroundColor=[UIColorcolorWithPatternImage:[UIImage imageNamed:bg.object]];
}
-(NSString *)whatjieqiis{
NSString *dpath=[[NSBundle mainBundle]pathForResource:@"jpdata"ofType:@"plist"];
NSMutableArray *jqbiao=[[NSMutableArrayalloc]initWithContentsOfFile:dpath];
int i;
for(i=0;i<[jqbiao count];i++){
NSDate *now=[NSDate date];
NSDate *jq=[jqbiao objectAtIndex:i];
NSDate *latedate=[jq laterDate:now];
if (latedate==jq) {
break;
}
}
NSString *ipath=[[NSBundle mainBundle]pathForResource:@"jqbg"ofType:@"plist"];
NSMutableArray *jqbg=[[NSMutableArrayalloc]initWithContentsOfFile:ipath];
NSString *bgurl=[jqbg objectAtIndex:i];
return bgurl;
[jqbg release];
[jqbiao release];
}
-(void)btnclick{
self.view.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:[self whatjieqiis]]];
AppDelegate *nowdelegate=[UIApplicationsharedApplication].delegate;
nowdelegate.window.backgroundColor=[UIColorcolorWithPatternImage:[UIImage imageNamed:[self whatjieqiis]]];
}
- 自定义背景颜色的设置
- #linux# 自定义设置vim的背景颜色
- POI设置自定义的RGB背景颜色
- Eclipse背景颜色自定义设置:
- ios 设置UITableView 选中行cell的背景颜色(自定义选中的背景颜色)
- 为一个视图设置自定义的背景颜色
- 自定义UITableViewCell的背景颜色
- 自定义UITableViewCell的背景颜色
- Pycharm如何设置自定义背景颜色
- 设置对话框的背景颜色
- 设置控件的背景颜色。
- 设置GtkEntry的背景颜色
- 设置uinavigationbar的背景颜色
- 设置tableViewCell的背景颜色
- UITableViewCell的背景颜色设置
- 设置Activity的背景颜色
- Myeclipse的背景颜色设置
- 设置progressbar的背景颜色
- Apache 和 Tomcat 简述(2)
- UITableView的常用属性
- eclipse tomcat 找不到 工程 解决方法~
- 取最大值和最小值(常数级复杂度)
- Spring3.3 整合 Hibernate3、MyBatis3.2 配置多数据源/动态切换数据源 方法
- 自定义背景颜色的设置
- jquery操作select(取值,设置选中)
- Java 获取系统信息
- 番茄时间管理
- linux shell 下各种进制数据转换。
- Android各种访问权限Permission详解
- sharpdevelop源码学习
- texture atlas or spritesheet 动画的实现
- Monitor name :Windows Resources. 无法连接计算机 192.168.32.230。 原因: 拒绝