zoukankan      html  css  js  c++  java
  • 学习IOS开发UI篇--UI知识点总结(一) UIButton/UITextField

      UIkit框架下的几个基本控件,UIButton,UITextField,UILabel,UIImageView,UIScrollView,UITableView,UITableViewCell,UIPageControl;

      他们的继承关系,UILabel,UIImageView,UIScrollView,UITableViewCell,直接继承自UIView;

             UIButton,UITextField,UIPageControl,继承自UIControl;

             UIControl继承自UIView;

      UIView的动画方法:

    + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion NS_AVAILABLE_IOS(4_0); // delay = 0.0, options = 0

     

      补充:在按钮中添加背景图片时候设计拉伸的方法

    - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets resizingMode:(UIImageResizingMode)resizingMode NS_AVAILABLE_IOS(6_0); // the interior is resized according to the resizingMode

    *** 需要设置按钮的contentEdgeInsets 属性 

    @property(nonatomic)          UIEdgeInsets contentEdgeInsets ; // default is UIEdgeInsetsZero

      UIButton:UIButton很常用,属性虽然简单,不过初学者常会弄不清楚;

      在设置属性的时候需要注意,UIButton中默认有

    @property(nonatomic,readonly,retain) UILabel     *titleLabel NS_AVAILABLE_IOS(3_0); (在UIButton不能创建titleLable属性)

    @property(nonatomic,readonly,retain) UIImageView *imageView  NS_AVAILABLE_IOS(3_0);

    @property(nonatomic,readonly,retain) NSString *currentTitle;             // normal/highlighted/selected/disabled. can return nil

    @property(nonatomic,readonly,retain) UIColor  *currentTitleColor;        // normal/highlighted/selected/disabled. always returns non-nil. default is white(1,1) 

      在调用方法的时候容易直接用点语法,导致显示错误,正确调用方法应该是

    - (void)setTitle:(NSString *)title forState:(UIControlState)state;                // default is nil. title is assumed to be single line

    - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state

    - (void)setImage:(UIImage *)image forState:(UIControlState)state;          // default is nil. should be same size if different for different states

      UITextFiled: 常用属性

    @property(nonatomic,copy)   NSString               *text;                 // default is nil

    @property(nonatomic,copy)   NSAttributedString     *attributedText NS_AVAILABLE_IOS(6_0); // default is nil

    @property(nonatomic,retain) UIColor                *textColor;            // default is nil. use opaque black

    @property(nonatomic,retain) UIFont                 *font;                 // default is nil. use system font 12 pt

    @property(nonatomic)        NSTextAlignment         textAlignment;        // default is NSLeftTextAlignment

    @property(nonatomic,retain) UIView              *leftView;        // e.g. magnifying glass (可以在左侧预留输入空白)

    @property(nonatomic)        UITextFieldViewMode  leftViewMode;    // sets when the left view shows up. default is UITextFieldViewModeNever

      代理方法:

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;        // return NO to disallow editing.

    - (void)textFieldDidBeginEditing:(UITextField *)textField;           // became first responder

    - (BOOL)textFieldShouldEndEditing:(UITextField *)textField;          // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to end

    - (void)textFieldDidEndEditing:(UITextField *)textField;             // may be called if forced even if shouldEndEditing returns NO (e.g. view removed from window) or endEditing:YES called 

    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;   // return NO to not change text 

    - (BOOL)textFieldShouldClear:(UITextField *)textField;               // called when clear button pressed. return NO to ignore (no notifications)

    - (BOOL)textFieldShouldReturn:(UITextField *)textField;              // called when 'return' key pressed. return NO to ignore.(在该方法中设置关闭键盘)

    
    

        

  • 相关阅读:
    window.open 子窗口关闭刷新父页面
    window.open打开新窗口报错ie 位指明错误,原因是window没有加引号!
    ORA-22922: 不存在的 LOB 值 可以使用外层嵌套wm_concat()解决
    子窗口打开父窗口
    页面加载时触发事件
    json
    orcale 函数wm_concat不存咋lob值使用zh_concat 替换
    mongo常见错误
    mongo中插入数据,出现id重复
    cpu占用率
  • 原文地址:https://www.cnblogs.com/zhaoyan/p/3763266.html
Copyright © 2011-2022 走看看