本篇還是以 x易x音樂為????
我們提供的服務有:成都網站建設、網站設計、微信公眾號開發、網站優化、網站認證、安岳ssl等。為近1000家企事業單位解決了網站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的安岳網站制作公司
如果沒有,那就創建一個 RHRevealLoader 文件夾,然后打開 Reveal ,如下操作
把這兩個文件復制到剛才創建的 RHRevealLoader 文件夾下
3,在手機上配置 Reveal Loader 插件 設置 -- Reveal -- Enableded Applications -- 把想查看的 App 開關打開
4,查看目標 App 的 UI 布局
首先確認 OS X 和 iOS 位于同一網段內,然后啟動 Reveal ,在啟動目標 App(如果App 之前是開著的,需要先管掉,再打開)
在App里切換了界面,可在 Reveal 界面中按 command + r 刷新。
匯報完畢,歡迎討論!
在開發過程中很多App為了美觀經常需要使用一些自定義的字體,其實蘋果本身也是支持很多字體的,下面就記錄一下查看所有字體并設置的方法,其實挺簡單的。
知道設置字體的方法了,就需要找出蘋果本身支持的所有字體了,一個for循環就可以搞定了。
下面是所有的效果,可以在下面直接找需要的字體
不過發現這些效果對中文好像沒什么效果,這就需要自定義字體了
1.將準備好的字體拉入項目中
2.打開Build Phases—Copy Bundle Resources,確保剛添加的字體文件在列表中,否則需要手動加到這里
3.編輯”項目名-Info.plist”文件
找到Fonts provided by application ,將加入的字體名連同擴展名填在這里
4.利用上面那個for循環打印出所有字體,并找到剛剛加入的字體
5.現在就可以使用了[UIFont fontWithName:@"chenweixun-yingxing" size:16];
一、簡單說明
一般情況下,點擊某個控件后,會做出相應反應的都是按鈕
按鈕的功能比較多,既能顯示文字,又能顯示圖片,還能隨時調整內部圖片和文字的位置
二、按鈕的三種狀態
normal(普通狀態)
默認情況(Default)
對應的枚舉常量:UIControlStateNormal
highlighted(高亮狀態)
按鈕被按下去的時候(手指還未松開)
對應的枚舉常量:UIControlStateHighlighted
disabled(失效狀態,不可用狀態)
如果enabled屬性為NO,就是處于disable狀態,代表按鈕不可以被點擊
對應的枚舉常量:UIControlStateDisabled
三、注意點
(1)從Xcode5開始,圖片資源都放到Images.xcassets中進行管理,可以使用拖拽的方式添加項目中用到的圖片到Images.xcassets中
(2)若干多個控件共用一段代碼,通常使用tag。
四、代碼示例
(1)
復制代碼 代碼如下:
#import "LFViewController.h"
@interface LFViewController ()
@property (weak, nonatomic) IBOutlet UIButton *headImageView;
@end
@implementation LFViewController
// 在OC中,絕大多數的控件的監聽方法的第一個參數就是控件本身
//- (IBAction)left:(UIButton *)button {
//
// NSLog(@"----");
//}
- (IBAction)move
{
// 通過frame修改head的位置
// 在OC中,不允許直接修改“對象”的“結構體屬性”的“成員”
// 允許修改“對象”的'“結構體屬性”
// 1. 取出結構體屬性
CGRect rect = self.headImageView.frame;
// 2. 修改結構體成員
rect.origin.y -= 20;
// 3. 設置對象的結構體屬性
self.headImageView.frame = rect;
}
(2)
復制代碼 代碼如下:
#import "LFViewController.h"
使用git
1. 創建項目時,勾選git
2. 開發告一段落后,選擇"Source Control""Commit",并編寫注釋
// 枚舉類型實質上就是一個整數,作用就是用來替代魔法數字
// 枚舉類型中,指定了第一個整數之后,后面的數字會遞增
typedef enum
kMovingDirTop = 10,
kMovingDirBottom,
kMovingDirLeft,
kMovingDirRight,
} kMovingDir;
#define kMovingDelta 50
@interface LFViewController ()
@property (weak, nonatomic) IBOutlet UIButton *headImageView;
@end
@implementation LFViewController
- (IBAction)move:(UIButton *)button
// CGRect rect = self.headImageView.frame;
CGPoint p = self.headImageView.center;
// magic number魔法數字,其他程序員看到代碼的時候,不知道是什么意思
switch (button.tag) {
case kMovingDirTop:
p.y -= kMovingDelta;
break;
case kMovingDirBottom:
p.y += kMovingDelta;
break;
case kMovingDirLeft:
p.x -= kMovingDelta;
break;
case kMovingDirRight:
p.x += kMovingDelta;
break;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
self.headImageView.center = p;
[UIView commitAnimations];
- (IBAction)zoom:(UIButton *)button
CGRect rect = self.headImageView.bounds;
// 在C語言中,關于bool的判斷:非零即真
if (button.tag) {
rect.size.width += 50;
rect.size.height += 50;
rect.size.width -= 50;
rect.size.height -= 50;
// 首尾動畫
// beginAnimations表示此后的代碼要“參與到”動畫中
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
self.headImageView.bounds = rect;
// self.headImageView.alpha = 0;
// commitAnimations,將beginAnimation之后的所有動畫提交并生成動畫
[UIView commitAnimations];
@end
五、補充筆記
1. IBAction的參數
- (IBAction)left:(UIButton *)button
(1) 在OC中,絕大多數的控件監聽方法的第一個參數就是控件本身
(2) 默認連線時的參數類型是id
(3) 如果要在監聽方法中,方便控件的使用,可以在連線時或者連線后,修改監聽方法的參數類型
2. 修改對象的結構體成員
在OC中,不允許直接修改“對象”的“結構體屬性”的“成員”,但是允許修改“對象”的“結構體屬性”
修改結構體屬性的成員方法如下:
(1)使用臨時變量記錄對象的結構體屬性
(2) 修改臨時變量的屬性
(3)將臨時變量重新設置給對象的結構體屬性
3. 在程序開發中需要避免出現魔法數字(Magic Number)
使用枚舉類型,可以避免在程序中出現魔法數字
(1)枚舉類型實質上就是一個整數,其作用就是用來替代魔法數字
(2)枚舉類型中,指定了第一個整數之后,后面的數字會遞增
4. frame bounds center
1 frame可以修改對象的位置和尺寸
2 bounds可以修改對象的尺寸
3 center可以修改對象的位置
5. 首尾式動畫
復制代碼 代碼如下:
// beginAnimations表示此后的代碼要“參與到”動畫中
[UIView beginAnimations:nil context:nil];
// setAnimationDuration用來指定動畫持續時間
[UIView setAnimationDuration:2.0];
self.headImageView.bounds = rect;
......
// commitAnimations,將beginAnimation之后的所有動畫提交并生成動畫
[UIView commitAnimations];
下面來羅列一下UIButton的基本屬性羅列
第一、UIButton的定義
復制代碼 代碼如下:
UIButton *button=[[UIButton buttonWithType:(UIButtonType);
能夠定義的button類型有以下6種,
復制代碼 代碼如下:
typedef enum {
UIButtonTypeCustom = 0, 自定義風格
UIButtonTypeRoundedRect, 圓角矩形
UIButtonTypeDetailDisclosure, 藍色小箭頭按鈕,主要做詳細說明用
UIButtonTypeInfoLight, 亮色感嘆號
UIButtonTypeInfoDark, 暗色感嘆號
UIButtonTypeContactAdd, 十字加號按鈕
}UIButtonType;
第二、設置frame
復制代碼 代碼如下:
button1.frame = CGRectMake(20, 20, 280, 40);
[button setFrame:CGRectMake(20,20,50,50)];
第三、button背景色
復制代碼 代碼如下:
button1.backgroundColor = [UIColor clearColor];
[button setBackgroundColor:[UIColor blueColor]];
第四、state狀態
forState: 這個參數的作用是定義按鈕的文字或圖片在何種狀態下才會顯現
復制代碼 代碼如下:
enum {
UIControlStateNormal = 0, 常規狀態顯現
UIControlStateHighlighted = 1 0, 高亮狀態顯現
UIControlStateDisabled = 1 1, 禁用的狀態才會顯現
UIControlStateSelected = 1 2, 選中狀態
UIControlStateApplication = 0x00FF0000, 當應用程序標志時
UIControlStateReserved = 0xFF000000 為內部框架預留,可以不管他
@property(nonatomic,getter=isEnabled)BOOL enabled; // default is YES. if NO, ignores touch events and subclasses may draw differently
@property(nonatomic,getter=isSelected)BOOL selected; // default is NO may be used by some subclasses or by application
@property(nonatomic,getter=isHighlighted)BOOL highlighted;
第五 、設置button填充圖片和背景圖片
復制代碼 代碼如下:
[buttonsetImage:[UIImageimageNamed:@"checkmarkControllerIcon"]forState:UIControlStateNormal];
[buttonsetBackgroundImage:[UIImageimageNamed:@"checkmarkControllerIcon"]forState:UIControlStateNormal];
第六、設置button標題和標題顏色
復制代碼 代碼如下:
[button1 setTitle:@"點擊" forState:UIControlStateNormal];
[buttonsetTitleColor:[UIColorredColor]forState:UIControlStateNormal];
第七、設置按鈕按下會發光
復制代碼 代碼如下:
button.showsTouchWhenHighlighted=NO;
第八、添加或刪除事件處理
復制代碼 代碼如下:
[button1 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
[btn removeTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
第九、 設置按鈕內部圖片間距和標題間距
復制代碼 代碼如下:
UIEdgeInsets insets; // 設置按鈕內部圖片間距
insets.top = insets.bottom = insets.right = insets.left = 10;
bt.contentEdgeInsets = insets;
bt.titleEdgeInsets = insets; // 標題間距
iOS開發UI篇—UITableviewcell的性能問題
一、UITableviewcell的一些介紹
UITableView的每一行都是一個UITableViewCell,通過dataSource的 tableView:cellForRowAtIndexPath:方法來初始化每?行
UITableViewCell內部有個默認的子視圖:contentView,contentView是UITableViewCell所顯示內容的父視圖,可顯示一些輔助指示視圖
輔助指示視圖的作?是顯示一個表示動作的圖標,可以通過設置UITableViewCell的 accessoryType來顯示,默認是UITableViewCellAccessoryNone(不顯?示輔助指?示視圖), 其他值如下:
UITableViewCellAccessoryDisclosureIndicator
UITableViewCellAccessoryDetailDisclosureButton
UITableViewCellAccessoryCheckmark
還可以通過cell的accessoryView屬性來自定義輔助指示視圖(?如往右邊放一個開關)
二、問題
cell的工作:在程序執行的時候,能看到多少條,它就創建多少條數據,如果視圖滾動那么再創建新顯示的內容。(系統自動調用)。即當一個cell出現在視野范圍內的時候,就會調用創建一個cell。這樣的邏輯看上去沒有什么問題,但是真的沒有任何問題嗎?
當創建調用的時候,我們使用nslog打印消息,并打印創建的cell的地址。我們發現如果數據量非常大,用戶在短時間內來回滾動的話,那么會創建大量的cell,一直開辟空間,且如果是往回滾,通過打印地址,我們會發現它并沒有重用之前已經創建的cell,而是重新創建,開辟新的存儲空間。
那有沒有什么好的解決辦法呢?
三、cell的重用原理
(1) iOS設備的內存有限,如果用UITableView顯示成千上萬條數據,就需要成千上萬 個UITableViewCell對象的話,那將會耗盡iOS設備的內存。要解決該問題,需要重用UITableViewCell對象
(2)重?原理:當滾動列表時,部分UITableViewCell會移出窗口,UITableView會將窗口外的UITableViewCell放入一個對象池中,等待重用。當UITableView要求dataSource返回 UITableViewCell時,dataSource會先查看這個對象池,如果池中有未使用的UITableViewCell,dataSource則會用新的數據來配置這個UITableViewCell,然后返回給 UITableView,重新顯示到窗口中,從而避免創建新對象 。這樣可以讓創建的cell的數量維持在很低的水平,如果一個窗口中只能顯示5個cell,那么cell重用之后,只需要創建6個cell就夠了。
(3)注意點:還有?個非常重要的問題:有時候需要自定義UITableViewCell(用?個子類繼 承UITableViewCell),而且每?行?的不一定是同一種UITableViewCell,所以一 個UITableView可能擁有不同類型的UITableViewCell,對象池中也會有很多不同類型的 UITableViewCell,那么UITableView在重?用UITableViewCell時可能會得到錯誤類型的 UITableViewCell
解決?方案:UITableViewCell有個NSString *reuseIdentifier屬性,可以在初始化UITableViewCell的時候傳入一個特定的字符串標識來設置reuseIdentifier(一般用UITableViewCell的類名)。當UITableView要求dataSource返回UITableViewCell時,先 通過一個字符串標識到對象池中查找對應類型的UITableViewCell對象,如果有,就重用,如果沒有,就傳入這個字符串標識來初始化?一個UITableViewCell對象。
圖片示例:
說明:一個窗口放得下(可視)三個cell,整個程序只需要創建4個該類型的cell即可。
四、cell的優化代碼
代碼示例:
1 #import "NJViewController.h"
2 #import "NJHero.h"
3
4 // #define ID @"ABC"
5
6 @interface NJViewController ()UITableViewDataSource, UITableViewDelegate
7 /**
8 * 保存所有的英雄數據
9 */
10 @property (nonatomic, strong) NSArray *heros;
11 @property (weak, nonatomic) IBOutlet UITableView *tableView;
12
13 @end
14
15 @implementation NJViewController
16
17 #pragma mark - 懶加載
18 - (NSArray *)heros
19 {
20 if (_heros == nil) {
21 // 1.獲得全路徑
22 NSString *fullPath = [[NSBundle mainBundle] pathForResource:@"heros" ofType:@"plist"];
23 // 2.更具全路徑加載數據
24 NSArray *dictArray = [NSArray arrayWithContentsOfFile:fullPath];
25 // 3.字典轉模型
26 NSMutableArray *models = [NSMutableArray arrayWithCapacity:dictArray.count];
27 for (NSDictionary *dict in dictArray) {
28 NJHero *hero = [NJHero heroWithDict:dict];
29 [models addObject:hero];
30 }
31 // 4.賦值數據
32 _heros = [models copy];
33 }
34 // 4.返回數據
35 return _heros;
36 }
37
38 - (void)viewDidLoad
39 {
40 [super viewDidLoad];
41 // 設置Cell的高度
42 // 當每一行的cell高度一致的時候使用屬性設置cell的高度
43 self.tableView.rowHeight = 160;
44 }
45
46 #pragma mark - UITableViewDataSource
47 // 返回多少組
48 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
49 {
50 return 1;
51 }
52 // 返回每一組有多少行
53 - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
54 {
55 return self.heros.count;
56 }
57 // 當一個cell出現視野范圍內的時候就會調用
58 // 返回哪一組的哪一行顯示什么內容
59 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
60 {
61 // 定義變量保存重用標記的值
62 static NSString *identifier = @"hero";
63
64 // 1.先去緩存池中查找是否有滿足條件的Cell
65 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
66 // 2.如果緩存池中沒有符合條件的cell,就自己創建一個Cell
67 if (cell == nil) {
68 // 3.創建Cell, 并且設置一個唯一的標記
69 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
70 NSLog(@"創建一個新的Cell");
71 }
72 // 4.給cell設置數據
73 NJHero *hero = self.heros[indexPath.row];
74 cell.textLabel.text = hero.name;
75 cell.detailTextLabel.text = hero.intro;
76 cell.imageView.image = [UIImage imageNamed:hero.icon];
77
78 // NSLog(@"%@ - %d - %p", hero.name, indexPath.row, cell);
79
80 // 3.返回cell
81 return cell;
82 }
83
84 #pragma mark - 控制狀態欄是否顯示
85 /**
86 * 返回YES代表隱藏狀態欄, NO相反
87 */
88 - (BOOL)prefersStatusBarHidden
89 {
90 return YES;
91 }
92 @end
網站欄目:ios開發ui篇,ios ui框架
本文來源:http://vcdvsql.cn/article40/dsdieho.html
成都網站建設公司_創新互聯,為您提供全網營銷推廣、軟件開發、微信公眾號、電子商務、定制開發、關鍵詞優化
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯