iOS UIButton各类属性设置大全

//设置自定义的按钮 //UIButton *button1=[UIButton buttonWithType:UIButtonTypeCustom]; //设置一个圆角的按钮 UIButton *button1=[UIButton buttonWithType:UIButtonTypeRoundedRect]; button1.frame=CGRectMake(80,250,250, 30);//按钮的位置坐标 [button1 setTitle:@"Button1" forState:UIControlStateNormal];//普通状态按钮标题 [button1 setTitle:@"高亮状态" forState:UIControlStateHighlighted];//高亮状态的按钮标题 //高亮状态光晕效果 [button1 setShowsTouchWhenHighlighted:YES]; //设置标题的颜色 [button1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; //设置标题的字体大小 [button1.titleLabel setFont:[UIFont boldSystemFontOfSize:20]]; //设置背景颜色 [button1 setBackgroundColor:[UIColor blueColor]]; //图片被拉伸式地设置背景图片 [button1 setBackgroundImage:[UIImage imageNamed:@"1.jpg"] forState:UIControlStateNormal]; //图片保持原来大小地设置背景图片 //[button1 setImage:[UIImage imageNamed:@"1.jpg"] forState:UIControlStateNormal]; [[button1 titleLabel]setShadowColor:[UIColor blackColor]]; [[button1 titleLabel]setShadowOffset:CGSizeMake(-0.5, -0.5)]; button1.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft; [self.view addSubview:button1];//监听事件 [button1 addTarget:self action:@selector(Click_Button) forControlEvents:UIControlEventTouchUpInside];}-(void)Click_Button{ NSLog(@"已点击…");}未完,待续更新………

,如你想要拥有完美无暇的友谊,可能一辈子找不到朋友

iOS UIButton各类属性设置大全

相关文章:

你感兴趣的文章:

标签云: