第一次用博客,早就想记录我的ios学习历程了,以后也有个留恋吧,由于本人还处于学习阶段,若有哪位高人无意浏览到,不足和错误支出还请多多指教,谢谢!
那么首先就从最常用的UIButton开始吧:
UIButton
“ViewController.m”
UIButton *saveButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
saveButton.frame=CGRectMake(self.view.frame.size.width-120, self.view.frame.size.height-170, 80, 40);
[saveButton setTitle:@"保存" forState:UIControlStateNormal];
[saveButton setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
saveButton.backgroundColor=[UIColor blueColor];
//设置按钮上内容各个方向上偏移量
saveButton.contentEdgeInsets=UIEdgeInsetsMake(0, 0, 0, 0);
//按下按钮会发光
saveButton.showsTouchWhenHighlighted=YES;
//设置内部图片按钮间距
UIEdgeInsets insets;
insets.bottom=insets.top=insets.left=insets.right=10;
saveButton.contentEdgeInsets=insets;
saveButton.titleEdgeInsets=insets;//标题间距
//设置按钮边框宽度及颜色
saveButton.layer.borderWidth=1.0;
saveButton.layer.borderColor=[[UIColor redColor]CGColor];
saveButton.layer.cornerRadius=20;//设置按钮矩形四个圆角半径
//添加点击事件
[saveButton addTarget:self action:@selector(saveTap) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:saveButton];
浙公网安备 33010602011771号