1.text:設置標籤顯示文本。
2.attributedText:設置標籤屬性文本。
示例Source:
NSString *text = @"first"; NSMutableAttributedString *textLabelStr = [[NSMutableAttributedString alloc] initWithString:text]; [textLabelStr setAttributes:@{NSForegroundColorAttributeName : [UIColor lightGrayColor], NSFontAttributeName : [UIFont systemFontOfSize:17]} range:NSMakeRange(11, 10)];
3.font:設置標籤文本字體。
示例Source:
label.font = [UIFont systemFontOfSize:17];
label.font = [UIFont fontWithName:@"Arial" size:16];
label.textColor = [UIColor blueColor];
4.textAlignment:設置標籤文本對齊方式。
示例Source:
label.textAlignment = NSTextAlignmentCenter;
5.lineBreakMode:設置標籤文字過長時的顯示方式,這個屬性使用於label中文本的換行和截短。首先numberofLines必須設置爲0,纔有效果。
示例Source:
label.numberOfLines = 0
label.lineBreakMode = NSLineBreakByCharWrapping; //以字符爲顯示單位顯示,後面部分省略不顯示。
label.lineBreakMode = NSLineBreakByClipping; //剪切與文本寬度相同的內容長度,後半部分被刪除。
label.lineBreakMode = NSLineBreakByTruncatingHead; //前面部分文字以……方式省略,顯示尾部文字內容。
label.lineBreakMode = NSLineBreakByTruncatingMiddle; //中間的內容以……方式省略,顯示頭尾的文字內容。
label.lineBreakMode = NSLineBreakByTruncatingTail; //結尾部分的內容以……方式省略,顯示頭的文字內容。
label.lineBreakMode = NSLineBreakByWordWrapping; //以單詞爲顯示單位顯示,後面部分省略不顯示。
6.enabled:設置文字內容是否可變。
7.adjustsFontSizeToFitWidth:文字內容自適應標籤寬度。
8.adjustsLetterSpacingToFitWidth:根據字母的間隔自適應標籤寬度,超出部分以……顯示。
9.numberOfLines:標籤最多顯示行數。
10.highlightedTextColor:設置文本高亮顯示顏色,與highlighted一起使用。
11.shadowColor:設置文本陰影顏色。
12.shadowOffset:設置文本陰影與原文本的偏移量。用法:label.shadowOffset =CGSizeMake(1.0, 5.0);
13.userInteractionEnabled:設置標籤是否忽略或移除用戶交互。默認爲NO。
14.preferredMaxLayoutWidth:優先選擇標籤佈局的最大寬度。
15.baselineAdjustment:如果adjustsFontSizeToFitWidth屬性設置爲YES,這個屬性就來控制文本基線的行爲。
示例Source:
label.baselineAdjustment = UIBaselineAdjustmentNone;
UIBaselineAdjustmentAlignBaselines,默認,文本最上端與中線對齊。
UIBaselineAdjustmentAlignCenters, 文本中線與label中線對齊。
UIBaselineAdjustmentNone, 文本最低端與label中線對齊。
16. backgroundColor 背景顏色
1.UIView
// 如果userInteractionEnabled=NO,不能跟用戶交互
@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled;
// 控件的標記(父控件通過標記可以找到對應的子控件)
@property(nonatomic) NSInteger tag;
// 控件的位置和尺寸(以父控件的左上角爲座標原點)
@property(nonatomic) CGRect frame;
// 控件的位置和尺寸(以控件本身的左上角爲座標原點)
@property(nonatomic) CGRect bounds;
// 控件的中點位置(以父控件的左上角爲座標原點)
@property(nonatomic) CGPoint center;
// 形變屬性:旋轉、縮放、平移
@property(nonatomic) CGAffineTransform transform;
// 父控件
@property(nonatomic,readonly) UIView *superview;
// 所有的子控件
@property(nonatomic,readonly,copy) NSArray *subviews;
2.UILabel
// 顯示的文字
@property(nonatomic,copy) NSString *text;
// 字體
@property(nonatomic,retain) UIFont *font;
// 文字顏色
@property(nonatomic,retain) UIColor *textColor;
// 文字的排列方式(左對齊、居中、右對齊)
@property(nonatomic) NSTextAlignment textAlignment;
// 設置行數(行數==0代表自動換行)
@property(nonatomic) NSInteger numberOfLines;
3.UIImageView
// 顯示的圖片
@property(nonatomic,retain) UIImage *image;
// 設置序列幀圖片數組(按順序播放animationImages數組中的圖片)
@property(nonatomic,copy) NSArray *animationImages;
// 序列幀動畫的持續時間
@property(nonatomic) NSTimeInterval animationDuration;
// 序列幀動畫的執行字數(默認是0,代表無限循環)
@property(nonatomic) NSInteger animationRepeatCount;
4.UIScrollView
// 表示UIScrollView所滾動的位置
@property(nonatomic) CGPoint contentOffset;
// 表示UIScrollView的內容尺寸(能滾動的範圍)
@property(nonatomic) CGSize contentSize;
// 增加UIScrollView額外的邊緣滾動區域
@property(nonatomic) UIEdgeInsets contentInset;
// 代理
@property(nonatomic,assign) id delegate;
5.UITableView
(前幾篇博客已經有很詳細的屬性介紹及使用) 需要查看的可以參考前幾篇博客。
6.UIPickerView
(前幾篇博客已經有很詳細的屬性介紹及使用) 需要查看的可以參考前幾篇博客。
7.UIControl
// 是否可用
@property(nonatomic,getter=isEnabled) BOOL enabled;
// 自動擁有很多種狀態
// 可以通過下面的方法來監聽控件內部的一些事件:點擊、值改變
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;
1> UIDatePicker
// 設置模式(類型)
@property(nonatomic) UIDatePickerMode datePickerMode;
// 設置區域(zh_CN代表天朝)
@property(nonatomic,retain) NSLocale *locale;
// 設置當前時間
@property(nonatomic,retain) NSDate *date;
// UIDatePicker內部顯示的日期更改了,就會觸發值改變事件
2> UISwitch
// 控制開關狀態
@property(nonatomic,getter=isOn) BOOL on;
- (void)setOn:(BOOL)on animated:(BOOL)animated;
// UISwitch內部開關狀態更改了,就會觸發值改變事件
3> UISegmentControl
// 一共有多少塊區域
@property(nonatomic,readonly) NSUInteger numberOfSegments;
// 當前選中區域的位置
@property(nonatomic) NSInteger selectedSegmentIndex;
// UISegmentControl內部選中的區域更改了,就會觸發值改變事件
4> UISlider
// 設置當前的進度值
@property(nonatomic) float value;
// 設置最小的進度值
@property(nonatomic) float minimumValue;
// 設置最大的進度值
@property(nonatomic) float maximumValue;
// UISlider內部的進度值更改了,就會觸發值改變事件
5> UIButton
// 快速創建一個按鈕
+ (id)buttonWithType:(UIButtonType)buttonType;
// 設置按鈕的內邊距
@property(nonatomic) UIEdgeInsets contentEdgeInsets;
// 按鈕內部的標籤控件
@property(nonatomic,readonly,retain) UILabel *titleLabel;
// 按鈕內部的圖片控件
@property(nonatomic,readonly,retain) UIImageView *imageView;
// 設置內部titleLabel顯示的文字
- (void)setTitle:(NSString *)title forState:(UIControlState)state;
// 設置內部titleLabel的文字顏色
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;
// 設置內部imageView顯示的圖片
- (void)setImage:(UIImage *)image forState:(UIControlState)state;
// 設置背景圖片
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state;
- (NSString *)titleForState:(UIControlState)state;
- (UIColor *)titleColorForState:(UIControlState)state;
- (UIImage *)imageForState:(UIControlState)state;
- (UIImage *)backgroundImageForState:(UIControlState)state;
6> UITextField(通過delegate監聽內部的事件)
8.UIAlertView
// 創建一個UIAlertView對話框
/*
title : 對話框標題
message : 對話框中間顯示的文字內容
cancelButtonTitle : 取消按鈕的文字
otherButtonTitles : 其他按鈕的文字(設置多個)
delegate : 用來監聽alertView上面按鈕的點擊
學習ios 重要還是要理清楚思路 在做或者看老師代碼的時候 自己多想想爲什麼 不要自己看着就抄 另外還是要推薦一下 藍懿IOS這個培訓機構 和劉國斌老師劉國斌老師還是很有名氣的,聽朋友說劉老師成立了藍懿iOS,,老師講課方式很獨特,能夠儘量讓每個人都能弄明白,有的比較難懂的地方,如果有的地方還是不懂得話,老師會換個其它方法再講解,這對於我們這些學習iOS的同學是非常好的,多種方式的講解會理解得更全面,這個必須得給個贊,嘻嘻,還有就是這裏的學習環境很好,很安靜,可以很安心的學習,安靜的環境是學習的基礎,小班講課,每個班20幾個學生,學習氛圍非常好,每天都學到9點多才離開教室,練習的時間很充裕,而且如果在練習的過程中有什麼困難,隨時可以向老師求助,不像其它機構,通過視頻教學,有的甚至學完之後都看不到講師本人,問點問題都不方便,這就是藍懿與其它機構的區別,相信在劉國斌老師的細心指導下,每個藍懿學員都能找到滿意的工作,加油!
寫博客第八十三天;
QQ:565803433