zoukankan      html  css  js  c++  java
  • 笔记(实习第一周)

    bounds的原点是(0,0),frame原点任意

    bounds指再本身坐标系统的位置

    frame是父坐标

    UITextField的重绘

    1. – textRectForBounds:     //重写来重置文字区域 
    2. – drawTextInRect:         //改变绘文字属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函数,就不用调用super了. 
    3. – placeholderRectForBounds:  //重写来重置占位符区域 
    4. – drawPlaceholderInRect:  //重写改变绘制占位符属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函数,就不用调用super了. 
    5. – borderRectForBounds:  //重写来重置边缘区域 
    6. – editingRectForBounds:  //重写来重置编辑区域 
    7. – clearButtonRectForBounds:  //重写来重置clearButton位置,改变size可能导致button的图片失真 
    8. – leftViewRectForBounds: 
    9. – rightViewRectForBounds: 
    10. TextFieldDelegate委托方法:
    11. 1、// 设置输入框,是否可以被修改
    12. // NO-将无法修改,不出现键盘
    13. // YES-可以修改,默认值 
    14. - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    15.     return YES;
    16. }
    17. 2、// 当点击键盘的返回键(右下角)时,执行该方法。
    18. // 一般用来隐藏键盘
    19. - (BOOL)textFieldShouldReturn:(UITextField *)textField{
    20.     if (txtAccount == textField) {
    21. [txtAccount resignFirstResponder];
    22. }
    23. return YES;
    24. }
    25. 3、// 当输入框获得焦点时,执行该方法。 
    26. - (void)textFieldDidBeginEditing:(UITextField *)textField{
    27.     NSLog(@"textFieldDidBeginEditing");
    28. }
    29. 4、// 指定是否允许文本字段结束编辑,允许的话,文本字段会失去first responder 
    30. - (BOOL)textFieldShouldEndEditing:(UITextField *)textField{
    31.     return YES;
    32. }
    33. 5、// 文本框失去first responder 时,执行 
    34. - (void)textFieldDidEndEditing:(UITextField *)textField{
    35.      NSLog(@"textFieldDidEndEditing");
    36. }
    37.  
    38. 6、// 指明是否允许根据用户请求清除内容
    39. - (BOOL)textFieldShouldClear:(UITextField *)textField{
    40.     NSLog(@"textFieldDidEndEditing");
    41.     return YES;
    42. }
    43. 7、// 文本框的文本,是否能被修改 
    44. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    45.     return YES;
    46. }

    在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

    目的是为了决定内容在图层的边界中怎么对齐。

  • 相关阅读:
    通信架构
    通信架构
    17.2?Replication Implementation 复制实施:
    17.2?Replication Implementation 复制实施:
    17.1.1.8?Setting Up Replication with Existing Data设置复制使用存在的数据
    17.1.1.8?Setting Up Replication with Existing Data设置复制使用存在的数据
    17.1.1.7 Setting Up Replication with New Master and Slaves 设置复制对于新的Master和Slaves:
    Hi3531用SPI FLASH启动 使用Nand做文件系统 分类: HI3531 2013-08-28 10:26 884人阅读 评论(0) 收藏
    Hi3531支持2GByte内存 分类: HI3531 2013-08-28 10:25 738人阅读 评论(0) 收藏
    Hi3531添加16GByte(128Gbit) NAND Flash支持 分类: HI3531 2013-08-28 10:23 861人阅读 评论(0) 收藏
  • 原文地址:https://www.cnblogs.com/durwards/p/4731084.html
Copyright © 2011-2022 走看看