UI 常用方法總結之--- UILabel UITextField (不斷更新中),uilabeluitextfield

來源:互聯網
上載者:User

UI 常用方法總結之--- UILabel UITextField (不斷更新中),uilabeluitextfield

UILabel :UIView <NSCoding>

1.建立一個UILabel對象

UILabel *label = [[UILabelalloc]initWithFrame:CGRectMake(30,30, 280,60)];


2.backgroundColor

背景顏色


3.text

顯示的文本資訊

eg:label.text =@"顯示的文本資訊";


4.textColor

文本顏色

eg:label.textColor = [UIColoryellowColor];


5.shadowColor

文本陰影顏色

eg:label.shadowColor = [UIColorblueColor];


6.shadowOffset

文本陰影位移

eg:label.shadowOffset =CGSizeMake(3, 3);


7.textAlignment

文本格式處理(對齊)

eg:label.textAlignment  =NSTextAlignmentCenter;


8.lineBreakMode

當文本過長時, label顯示的斷行方式

eg:label.lineBreakMode =NSLineBreakByTruncatingHead;


9.numberOfLines

控制label顯示的行數

eg:label.numberOfLines =0;


10.font

字型大小  系統預設字型大小17

eg:label.font = [UIFontsystemFontOfSize:20];




UITextField :UIControl <UITextInput,NSCoding> 


1.建立一個UITextField對象

UITextField *name = [[UITextFieldalloc]initWithFrame:CGRectMake(30,100,280, 30)];


2.placeholder

預設的佔位字串 一旦輸入自動隱藏

eg:name.placeholder =@"請在這裡輸入";


3.secureTextEntry

輸入轉換為黑點

eg:name.secureTextEntry =YES;


4.keyboardType

更改鍵盤類型

name.keyboardType =UIKeyboardTypeASCIICapable;


5.borderStyle

外觀控制

name.borderStyle =UITextBorderStyleRoundedRect;


6.clearButtonMode

清除按鈕

name.clearButtonMode =UITextFieldViewModeWhileEditing;


7.backgroundColor

背景顏色


8.回收鍵盤操作

[textField resignFirstResponder];


9.- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;      

//是否允許輸入


10.- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;

//限制輸入字元

eg:   if ([stringisEqualToString:@"a"]) {

        

        returnNO;

    }

    NSLog(@"%@",string);

    returnYES;


11.- (BOOL)textFieldShouldReturn:(UITextField *)textField;   

//返回按鈕調用方法


IOS 中UITextField UILabel有什不同?UITextField是繼承UIControl UILabel 是繼承UIView;

UITextField 可以進行編輯輸入,UILabel不可以. UITextField輸入時有代理進行操作響應.
我特別不理解你拿他倆做什麼比較 你想什麼地方用,有個前提是不是你說的才比較明白
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.