笔记(实习第一周)
2015-08-14 20:10
260 查看
bounds的原点是(0,0),frame原点任意
bounds指再本身坐标系统的位置
frame是父坐标
UITextField的重绘
– textRectForBounds: //重写来重置文字区域
– drawTextInRect: //改变绘文字属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函数,就不用调用super了.
– placeholderRectForBounds: //重写来重置占位符区域
– drawPlaceholderInRect: //重写改变绘制占位符属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函数,就不用调用super了.
– borderRectForBounds: //重写来重置边缘区域
– editingRectForBounds: //重写来重置编辑区域
– clearButtonRectForBounds: //重写来重置clearButton位置,改变size可能导致button的图片失真
– leftViewRectForBounds:
– rightViewRectForBounds:
TextFieldDelegate委托方法:
1、// 设置输入框,是否可以被修改
// NO-将无法修改,不出现键盘
// YES-可以修改,默认值
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
return YES;
}
2、// 当点击键盘的返回键(右下角)时,执行该方法。
// 一般用来隐藏键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
if (txtAccount == textField) {
[txtAccount resignFirstResponder];
}
return YES;
}
3、// 当输入框获得焦点时,执行该方法。
- (void)textFieldDidBeginEditing:(UITextField *)textField{
NSLog(@"textFieldDidBeginEditing");
}
4、// 指定是否允许文本字段结束编辑,允许的话,文本字段会失去first responder
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
return YES;
}
5、// 文本框失去first responder 时,执行
- (void)textFieldDidEndEditing:(UITextField *)textField{
NSLog(@"textFieldDidEndEditing");
}
6、// 指明是否允许根据用户请求清除内容
- (BOOL)textFieldShouldClear:(UITextField *)textField{
NSLog(@"textFieldDidEndEditing");
return YES;
}
7、// 文本框的文本,是否能被修改
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
return YES;
}
在iOS 7中,苹果引入了一个新的属性,叫做[UIViewController setEdgesForExtendedLayout:],它的默认值为UIRectEdgeAll。当你的容器是navigation controller时,默认的布局将从navigation bar的顶部开始。这就是为什么所有的UI元素都往上漂移了44pt。
修复这个问题的快速方法就是在方法- (void)viewDidLoad中添加如下一行代码:
这样问题就修复了。
contentSize、contentInset和contentOffset 是 scrollView三个基本的属性。
contentSize:
其实就是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。
contentOffset:
是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480
contentInset:
是scrollview的contentview的顶点相对于scrollview的位置,例如你的contentInset = (0 ,100),那么你的contentview就是从scrollview的(0 ,100)开始显示
loadingView一般采用0.8的透明度
//控制font的长度
if (size.width < 40.0f)
size.width = 40.0f;
else if (size.width > 60.0f)
size.width = 60.0f;
//从sdk7开始,rightBarButtonItem按钮比以前的版本左移了20个像素,而且sdk不提供设置rightBarButtonItem位置的方法,所以只能将贴图右偏
rightBarButton.imageEdgeInsets = UIEdgeInsetsMake(0,5,0,-5);
60s倒计时
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
自动布局中
autoresizingMask属性有
enum {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
UIViewAutoresizingNone就是不自动调整。
UIViewAutoresizingFlexibleLeftMargin 自动调整与superView左边的距离,保证与superView右边的距离不变。
UIViewAutoresizingFlexibleRightMargin 自动调整与superView的右边距离,保证与superView左边的距离不变。
UIViewAutoresizingFlexibleTopMargin 自动调整与superView顶部的距离,保证与superView底部的距离不变。
UIViewAutoresizingFlexibleBottomMargin 自动调整与superView底部的距离,也就是说,与superView顶部的距离不变。
UIViewAutoresizingFlexibleWidth 自动调整自己的宽度,保证与superView左边和右边的距离不变。
UIViewAutoresizingFlexibleHeight 自动调整自己的高度,保证与superView顶部和底部的距离不变。
autoresizingMask属性主要指的是如果父控件发生变化,比如说原来是320*480,发生了变化414*736,其中的view会发生等比例变化;
CALayer里的contentsGravity属性可选的有
kCAGravityCenter
kCAGravityTop
kCAGravityBottom
kCAGravityLeft
kCAGravityRight
kCAGravityTopLeft
kCAGravityTopRight
kCAGravityBottomLeft
kCAGravityBottomRight
kCAGravityResize
kCAGravityResizeAspect
kCAGravityResizeAspectFill
目的是为了决定内容在图层的边界中怎么对齐。
bounds指再本身坐标系统的位置
frame是父坐标
UITextField的重绘
– textRectForBounds: //重写来重置文字区域
– drawTextInRect: //改变绘文字属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函数,就不用调用super了.
– placeholderRectForBounds: //重写来重置占位符区域
– drawPlaceholderInRect: //重写改变绘制占位符属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函数,就不用调用super了.
– borderRectForBounds: //重写来重置边缘区域
– editingRectForBounds: //重写来重置编辑区域
– clearButtonRectForBounds: //重写来重置clearButton位置,改变size可能导致button的图片失真
– leftViewRectForBounds:
– rightViewRectForBounds:
TextFieldDelegate委托方法:
1、// 设置输入框,是否可以被修改
// NO-将无法修改,不出现键盘
// YES-可以修改,默认值
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
return YES;
}
2、// 当点击键盘的返回键(右下角)时,执行该方法。
// 一般用来隐藏键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
if (txtAccount == textField) {
[txtAccount resignFirstResponder];
}
return YES;
}
3、// 当输入框获得焦点时,执行该方法。
- (void)textFieldDidBeginEditing:(UITextField *)textField{
NSLog(@"textFieldDidBeginEditing");
}
4、// 指定是否允许文本字段结束编辑,允许的话,文本字段会失去first responder
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
return YES;
}
5、// 文本框失去first responder 时,执行
- (void)textFieldDidEndEditing:(UITextField *)textField{
NSLog(@"textFieldDidEndEditing");
}
6、// 指明是否允许根据用户请求清除内容
- (BOOL)textFieldShouldClear:(UITextField *)textField{
NSLog(@"textFieldDidEndEditing");
return YES;
}
7、// 文本框的文本,是否能被修改
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
return YES;
}
在iOS 7中,苹果引入了一个新的属性,叫做[UIViewController setEdgesForExtendedLayout:],它的默认值为UIRectEdgeAll。当你的容器是navigation controller时,默认的布局将从navigation bar的顶部开始。这就是为什么所有的UI元素都往上漂移了44pt。
修复这个问题的快速方法就是在方法- (void)viewDidLoad中添加如下一行代码:
1 | self.edgesForExtendedLayout = UIRectEdgeNone; |
contentSize、contentInset和contentOffset 是 scrollView三个基本的属性。
contentSize:
其实就是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。
contentOffset:
是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480
contentInset:
是scrollview的contentview的顶点相对于scrollview的位置,例如你的contentInset = (0 ,100),那么你的contentview就是从scrollview的(0 ,100)开始显示
loadingView一般采用0.8的透明度
//控制font的长度
if (size.width < 40.0f)
size.width = 40.0f;
else if (size.width > 60.0f)
size.width = 60.0f;
//从sdk7开始,rightBarButtonItem按钮比以前的版本左移了20个像素,而且sdk不提供设置rightBarButtonItem位置的方法,所以只能将贴图右偏
rightBarButton.imageEdgeInsets = UIEdgeInsetsMake(0,5,0,-5);
60s倒计时
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
自动布局中
autoresizingMask属性有
enum {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
UIViewAutoresizingNone就是不自动调整。
UIViewAutoresizingFlexibleLeftMargin 自动调整与superView左边的距离,保证与superView右边的距离不变。
UIViewAutoresizingFlexibleRightMargin 自动调整与superView的右边距离,保证与superView左边的距离不变。
UIViewAutoresizingFlexibleTopMargin 自动调整与superView顶部的距离,保证与superView底部的距离不变。
UIViewAutoresizingFlexibleBottomMargin 自动调整与superView底部的距离,也就是说,与superView顶部的距离不变。
UIViewAutoresizingFlexibleWidth 自动调整自己的宽度,保证与superView左边和右边的距离不变。
UIViewAutoresizingFlexibleHeight 自动调整自己的高度,保证与superView顶部和底部的距离不变。
autoresizingMask属性主要指的是如果父控件发生变化,比如说原来是320*480,发生了变化414*736,其中的view会发生等比例变化;
CALayer里的contentsGravity属性可选的有
kCAGravityCenter
kCAGravityTop
kCAGravityBottom
kCAGravityLeft
kCAGravityRight
kCAGravityTopLeft
kCAGravityTopRight
kCAGravityBottomLeft
kCAGravityBottomRight
kCAGravityResize
kCAGravityResizeAspect
kCAGravityResizeAspectFill
目的是为了决定内容在图层的边界中怎么对齐。
相关文章推荐
- CodeForces 14D 树的直径 Two Paths
- Triangle LOVE(拓扑排序)
- 智渔课堂官方免费教程四十五 :Java算法之递归算法
- Reward HDU杭电2647【反向拓扑+队列】
- poj 3070 矩阵连乘简单题
- Docker安装应用程序(Centos6.5_x64)
- I学霸官方免费教程四十五 :Java算法之递归算法
- Triangle LOVE(拓扑排序)
- 树莓派用Python写几个简单程序4:socket的使用
- LCS 算法
- HDU 5378 Leader in Tree Land
- 蚂蜂窝特价 v4.4.0 官方安卓版
- Android 入门指引 从零基础学安卓怎么开始
- asp.net mvc dropdownlist
- iOS SDK详解之NSCoding协议
- Codeforces Gym 100379G Wythoff’s game with three piles 博弈
- hdu 4277 USACO ORZ(dfs+剪枝)
- hdu 5381 The sum of gcd 莫队 + DP
- Hdu 2015 Multi-University Training Contest8
- Hit 2255 Not Fibonacci