1.5拓展
2019-04-08 本文已影响0人
草根小强
Tag : 这个是用来设置数字的 可以通过数字来判断用户是按到的哪个按钮。
frame:可以修改 控件位置和大小 //获取的x和y表示的是元素左上角的坐标。//放大的时候 左上角坐标不变。//CGrect类型
originFrame.origin.y + = 10;
center :只能修改位置//表示控件中心点的坐标。
CGPoint centerPoint = self.btnIcon.center 。
centerPoint.y - = 10;
bounds :只能修改大小 //放大的时候中心点不变
//CGRect类型
CGrect originBounds = self.btnIcon.bounds;]
// NSLog(@“%@”,NSStringFromCGRect(originBounds));
origninBounds.size.width += 10;
originBounds.size.height + = 10;
transform 可以修改控件的大小 位置 旋转。
UIButton的状态
//如果不想让按钮变成灰色,将按钮属性设置成custton
1.nomal(普通状态)
1》默认情况(Default)
2>对应的枚举常量:UIControlStateNormal
2.highighted(高亮状态)
1》按钮按下去的时候(手指未松开的时候)
2》对应的枚举常量:UIControlStateHighlighted
3.disabled(失效状态,不可用状态)
1》如果enabled属性为NO,就是处于disable状态,代表按钮不可以被点击
2》对应的枚举常量:UIControlStateDisabled
二:动画
//实现动漫方式以一:头尾式
//通过动画的方式来执行
//上下左右 放大和缩小动画
//1.开启一个动画
[UIView beginAnimations:nil context:nil];
//2.设置动画执行时间
[UIview setAnimationDuration:2];
//======中间这里是要执行的动漫的代码======
self.btnIcon.cemter = centerPoint;
//=====中间这里是要执行的动漫的代码=======
//3.提交动画
[UIView commitAnimations];
实现动漫方式二:
[UIView animateWithDuration:1.0 animations:^{
self.btnIcon.frame = originFrame;
}];
动态创建控件: 是用编写代码来执行的。
见视频动态创建按钮02
//创建一个自定义的按钮
UIButton *btn = [UIButton buttonWithType:UIBUttonTypeCustom];
//默认状态的背景
[btn setBackgroundImage:[UIImage imageNamed:@“btn_01”] forState:UIControlStateNormall];
//默认状态下的文字
[btn setTiltle:@“”forState:UICountrolStateNormal];
//默认状态的文字颜色
[btn setTileColor:[UIcolor redColor] forState:UIControlStateNormal];