// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
UIImageView * imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"时间.jpg"]];
imageView.tag=100;//没有设置成为属性,后面在其他函数内用到,设个tag来获取
[self.window addSubview:imageView];
[imageView release];//alloc了就release
UIButton * button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame=CGRectMake(100, 100, 100, 100);
[button addTarget:self action:@selector(changeImage) forControlEvents:UIControlEventTouchUpInside];//添加一个Button来改变imageView的image属性的值。
[self.window addSubview:button];
[self.window makeKeyAndVisible];
return YES;
以上直接写在
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 里面。
button对应的事件如下:
-(void)changeImage
{
UIImageView * v1=(UIImageView *)[self.window viewWithTag:100];
v1.image=[UIImage imageNamed:@"双子座.jpg"];
}
应该说清楚了。