亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

114自定義UITableViewCell(擴展知識:為UITableViewCell添加動畫效果)

2019-11-14 18:50:47
字體:
來源:轉載
供稿:網友

關鍵操作:

效果如下:

ViewController.h

1 #import <UIKit/UIKit.h>2 3 @interface ViewController : UITableViewController4 @PRoperty (strong, nonatomic) NSMutableArray *mArrDataList;5 @property (strong, nonatomic) NSMutableArray *mArrImageList;6 7 @end

ViewController.m

  1 #import "ViewController.h"  2 #import "KMTableViewCell.h"  3   4 @interface ViewController ()  5 - (void)layoutUI;  6 - (void)loadData;  7 @end  8   9 @implementation ViewController 10  11 - (void)viewDidLoad { 12     [super viewDidLoad]; 13      14     [self layoutUI]; 15 } 16  17 - (void)didReceiveMemoryWarning { 18     [super didReceiveMemoryWarning]; 19     // Dispose of any resources that can be recreated. 20 } 21  22  23 - (void)layoutUI { 24     [self loadData]; 25      26     self.view.backgroundColor = [UIColor whiteColor]; 27     self.navigationItem.title = @"自定義UITableViewCell"; 28 } 29  30 - (void)loadData { 31     NSBundle *bundle = [NSBundle mainBundle]; 32     NSURL *urlFriendsInfo = [bundle URLForResource:@"FriendsInfo" withExtension:@"plist"]; 33     NSDictionary *dicFriendsInfo = [NSDictionary dictionaryWithContentsOfURL:urlFriendsInfo]; 34     NSInteger len = [dicFriendsInfo count]; 35     _mArrDataList = [[NSMutableArray alloc] initWithCapacity:len]; 36     _mArrImageList = [[NSMutableArray alloc] initWithCapacity:len]; 37     for (NSInteger i=0; i<len; i++) { 38         NSString *strKey = [NSString stringWithFormat:@"%lu", (unsigned long)(i+1)]; 39         NSDictionary *dicData = [dicFriendsInfo objectForKey:strKey]; 40         [_mArrDataList addObject:dicData]; 41          42         UIImage *img = [UIImage imageNamed:strKey]; 43         [_mArrImageList addObject:img]; 44     } 45 } 46  47 #pragma mark - TableView DataSource and Delegate 48 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 49     return @"FriendsInfo列表"; 50 } 51  52 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 53     return 1; 54 } 55  56 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 57     return [_mArrDataList count]; 58 } 59  60 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 61     static NSString *cellIdentifier = @"cellIdentifier"; 62     static BOOL isRegistered = NO; 63     if (!isRegistered) { 64         UINib *nib = [UINib nibWithNibName:@"KMTableViewCell" bundle:nil]; 65         [tableView registerNib:nib forCellReuseIdentifier:cellIdentifier]; 66         isRegistered = YES; 67     } 68     KMTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 69     if (!cell) { 70         cell = [[KMTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 71     } 72      73     NSDictionary *rowData = _mArrDataList[indexPath.row]; 74     cell.name = [rowData objectForKey:@"name"]; 75     cell.desc = [rowData objectForKey:@"desc"]; 76     cell.location = [rowData objectForKey:@"location"]; 77     cell.imgCustom = _mArrImageList[indexPath.row]; 78     return cell; 79 } 80  81 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 82     return 60.0; 83 } 84  85 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 86     // 從錨點位置出發,逆時針繞 Y 和 Z 坐標軸旋轉90度 87     CATransform3D transform3D = CATransform3DMakeRotation(M_PI_2, 0.0, 1.0, 1.0); 88      89     // 定義 cell 的初始狀態 90     cell.alpha = 0.0; 91     cell.layer.transform = transform3D; 92     cell.layer.anchorPoint = CGPointMake(0.0, 0.5); // 設置錨點位置;默認為中心點(0.5, 0.5) 93      94     // 定義 cell 的最終狀態,執行動畫效果 95     // 方式一:普通操作設置動畫 96 //    [UIView beginAnimations:@"transform" context:NULL]; 97 //    [UIView setAnimationDuration:0.5]; 98 //    cell.alpha = 1.0; 99 //    cell.layer.transform = CATransform3DIdentity;100 //    CGRect rect = cell.frame;101 //    rect.origin.x = 0.0;102 //    cell.frame = rect;103 //    [UIView commitAnimations];104     105     // 方式二:代碼塊設置動畫106     [UIView animateWithDuration:0.5 animations:^{107         cell.alpha = 1.0;108         cell.layer.transform = CATransform3DIdentity;109         CGRect rect = cell.frame;110         rect.origin.x = 0.0;111         cell.frame = rect;112     }];113 }114 115 @end

KMTableViewCell.h

 1 #import <UIKit/UIKit.h> 2  3 @interface KMTableViewCell : UITableViewCell 4 @property (strong, nonatomic) IBOutlet UIImageView *imgVCustom; 5 @property (strong, nonatomic) IBOutlet UILabel *lblName; 6 @property (strong, nonatomic) IBOutlet UILabel *lblDesc; 7 @property (strong, nonatomic) IBOutlet UILabel *lblLocation; 8 @property (copy, nonatomic) UIImage *imgCustom; 9 @property (copy, nonatomic) NSString *name;10 @property (copy, nonatomic) NSString *desc;11 @property (copy, nonatomic) NSString *location;12 13 @end

KMTableViewCell.m

 1 #import "KMTableViewCell.h" 2  3 @implementation KMTableViewCell 4  5 - (void)awakeFromNib { 6     // Initialization code 7 } 8  9 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {10     [super setSelected:selected animated:animated];11     // Configure the view for the selected state12 }13 14 - (void)setImgCustom:(UIImage *)imgCustom {15     if (![_imgCustom isEqual:imgCustom]) {16         _imgCustom = [imgCustom copy];17         _imgVCustom.image = _imgCustom;18     }19 }20 21 - (void)setName:(NSString *)name {22     if (![_name isEqualToString:name]) {23         _name = [name copy];24         _lblName.text = _name;25     }26 }27 28 - (void)setDesc:(NSString *)desc {29     if (![_desc isEqualToString:desc]) {30         _desc = [desc copy];31         _lblDesc.text = _desc;32     }33 }34 35 - (void)setLocation:(NSString *)location {36     if (![_location isEqualToString:location]) {37         _location = [location copy];38         _lblLocation.text = _location;39     }40 }41 42 @end

KMTableViewCell.xib

 1 <?xml version="1.0" encoding="UTF-8" standalone="no"?> 2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyaccessControl="none" useAutolayout="YES" useTraitCollections="YES"> 3     <dependencies> 4         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/> 5     </dependencies> 6     <objects> 7         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> 8         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> 9         <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cellIdentifier" id="KGk-i7-Jjw" customClass="KMTableViewCell">10             <rect key="frame" x="0.0" y="0.0" width="320" height="60"/>11             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>12             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">13                 <rect key="frame" x="0.0" y="0.0" width="320" height="43"/>14                 <autoresizingMask key="autoresizingMask"/>15                 <subviews>16                     <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Br-R7-YsD">17                         <rect key="frame" x="10" y="5" width="50" height="50"/>18                     </imageView>19                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dJA-8r-pcJ">20                         <rect key="frame" x="78" y="19" width="200" height="21"/>21                         <fontDescription key="fontDescription" type="system" pointSize="12"/>22                         <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>23                         <nil key="highlightedColor"/>24                     </label>25                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5h7-UD-fzl">26                         <rect key="frame" x="78" y="38" width="42" height="21"/>27                         <fontDescription key="fontDescription" type="system" pointSize="12"/>28                         <color key="textColor" red="0.517578125" green="0.517578125" blue="0.517578125" alpha="1" colorSpace="calibratedRGB"/>29                         <nil key="highlightedColor"/>30                     </label>31                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kPR-pa-8uG">32                         <rect key="frame" x="78" y="0.0" width="42" height="21"/>33                         <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>34                         <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>35                         <nil key="highlightedColor"/>36                     </label>37                 </subviews>38             </tableViewCellContentView>39             <connections>40                 <outlet property="imgVCustom" destination="3Br-R7-YsD" id="ODd-v8-Lem"/>41                 <outlet property="lblDesc" destination="dJA-8r-pcJ" id="SFw-6v-VAS"/>42                 <outlet property="lblLocation" destination="5h7-UD-fzl" id="W60-wQ-S2r"/>43                 <outlet property="lblName" destination="kPR-pa-8uG" id="BH7-oj-3Kx"/>44             </connections>45         </tableViewCell>46     </objects>47 </document>

AppDelegate.h

1 #import <UIKit/UIKit.h>2 3 @interface AppDelegate : UIResponder <UIapplicationDelegate>4 @property (strong, nonatomic) UIWindow *window;5 @property (strong, nonatomic) UINavigationController *navigationController;6 7 @end

AppDelegate.m

 1 #import "AppDelegate.h" 2 #import "ViewController.h" 3  4 @interface AppDelegate () 5 @end 6  7 @implementation AppDelegate 8  9 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {10     _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];11     ViewController *viewController = [[ViewController alloc] init];12     _navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];13     _window.rootViewController = _navigationController;14     //[_window addSubview:_navigationController.view]; //當_window.rootViewController關聯時,這一句可有可無15     [_window makeKeyAndVisible];16     return YES;17 }18 19 - (void)applicationWillResignActive:(UIApplication *)application {20 }21 22 - (void)applicationDidEnterBackground:(UIApplication *)application {23 }24 25 - (void)applicationWillEnterForeground:(UIApplication *)application {26 }27 28 - (void)applicationDidBecomeActive:(UIApplication *)application {29 }30 31 - (void)applicationWillTerminate:(UIApplication *)application {32 }33 34 @end

FriendsInfo.plist

  1 <?xml version="1.0" encoding="UTF-8"?>  2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">  3 <plist version="1.0">  4 <dict>  5     <key>1</key>  6     <dict>  7         <key>name</key>  8         <string>小明</string>  9         <key>desc</key> 10         <string>干啥呢?</string> 11         <key>location</key> 12         <string>廣州</string> 13     </dict> 14     <key>2</key> 15     <dict> 16         <key>name</key> 17         <string>痞子</string> 18         <key>desc</key> 19         <string>好好學習,天天向上!</string> 20         <key>location</key> 21         <string>廣州</string> 22     </dict> 23     <key>3</key> 24     <dict> 25         <key>name</key> 26         <string>瘋子</string> 27         <key>desc</key> 28         <string>倚樓聽風雨,淡看江湖路。</string> 29         <key>location</key> 30         <string>廣州</string> 31     </dict> 32     <key>4</key> 33     <dict> 34         <key>name</key> 35         <string>夢醒</string> 36         <key>desc</key> 37         <string>書到用時方恨少</string> 38         <key>location</key> 39         <string>廣州</string> 40     </dict> 41     <key>5</key> 42     <dict> 43         <key>name</key> 44         <string>落落</string> 45         <key>desc</key> 46         <string>生日快樂!</string> 47         <key>location</key> 48         <string>廣州</string> 49     </dict> 50     <key>6</key> 51     <dict> 52         <key>name</key> 53         <string>丫丫</string> 54         <key>desc</key> 55         <string>做個踏實的科研女</string> 56         <key>location</key> 57         <string>廣州</string> 58     </dict> 59     <key>7</key> 60     <dict> 61         <key>name</key> 62         <string>樂天平</string> 63         <key>desc</key> 64         <string>在火車上</string> 65         <key>location</key> 66         <string>廣州</string> 67     </dict> 68     <key>8</key> 69     <dict> 70         <key>name</key> 71         <string>北暮</string> 72         <key>desc</key> 73         <string>好久不見!</string> 74         <key>location</key> 75         <string>廣州</string> 76     </dict> 77     <key>9</key> 78     <dict> 79         <key>name</key> 80         <string>蘋果</string> 81         <key>desc</key> 82         <string>喜歡蘋果,更喜歡青蘋果!</string> 83         <key>location</key> 84         <string>廣州</string> 85     </dict> 86     <key>10</key> 87     <dict> 88         <key>name</key> 89         <string>木頭</string> 90         <key>desc</key> 91         <string>清心薄欲 靜躁作學</string> 92         <key>location</key> 93         <string>廣州</string> 94     </dict> 95     <key>11</key> 96     <dict> 97         <key>name</key> 98         <string>醉清風</string> 99         <key>desc</key>100         <string>一醉解千愁</string>101         <key>location</key>102         <string>廣州</string>103     </dict>104     <key>12</key>105     <dict>106         <key>name</key>107         <string>淺の斯</string>108         <key>desc</key>109         <string>想剪短發……剪還是不剪(⊙o⊙)?</string>110         <key>location</key>111         <string>廣州</string>112     </dict>113     <key>13</key>114     <dict>115         <key>name</key>116         <string>虛偽</string>117         <key>desc</key>118         <string>討厭虛偽</string>119         <key>location</key>120         <string>廣州</string>121     </dict>122     <key>14</key>123     <dict>124         <key>name</key>125         <string>閣樓</string>126         <key>desc</key>127         <string>窗外的風景。</string>128         <key>location</key>129         <string>廣州</string>130     </dict>131 </dict>132 </plist>

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日本精品视频在线| 久久久999国产精品| 久久综合88中文色鬼| 亚洲精品91美女久久久久久久| 国产亚洲激情在线| 国产精品欧美一区二区三区奶水| 国产精品丝袜一区二区三区| 久久久久久国产精品| 欧美日韩国产在线| 色综合导航网站| 日韩精品在线影院| 亚洲自拍偷拍第一页| 日韩中文字幕亚洲| 久久精品国产91精品亚洲| 亚洲大胆人体在线| 国产精品久久久久久五月尺| 国产精品2018| 精品无码久久久久久国产| 欧美性感美女h网站在线观看免费| 久久久999精品免费| 国产噜噜噜噜噜久久久久久久久| 日韩在线中文字| 97久久精品人搡人人玩| 97超级碰在线看视频免费在线看| 日韩女优在线播放| 亚洲精品日韩av| 欧美日韩国产精品一区二区三区四区| 国产精品海角社区在线观看| 中日韩美女免费视频网站在线观看| 中文字幕久热精品在线视频| 在线亚洲国产精品网| 亚洲福利视频免费观看| 日本欧美一级片| 狠狠干狠狠久久| 国产精品极品美女粉嫩高清在线| 日韩欧美亚洲成人| 91在线网站视频| 日韩电影大全免费观看2023年上| 亚洲大胆美女视频| 久久影视电视剧免费网站清宫辞电视| 欧美不卡视频一区发布| 欧美激情影音先锋| 久久香蕉精品香蕉| 日本久久亚洲电影| 午夜精品久久久久久久久久久久久| 中文日韩在线观看| 亚洲欧美国产精品久久久久久久| 色综合久久88色综合天天看泰| 国产精品国产福利国产秒拍| 国产精品中文久久久久久久| 国产色综合天天综合网| 国产精品人成电影| 国产一区二区三区日韩欧美| 亚洲a∨日韩av高清在线观看| 久久久久久久网站| 亚洲人成免费电影| 色yeye香蕉凹凸一区二区av| 久久亚洲电影天堂| 欧美成人三级视频网站| 国产成人激情视频| 九九精品在线播放| 91久久久久久久久久久| 亚洲аv电影天堂网| 欧美一级电影免费在线观看| 国产成人在线精品| 成人伊人精品色xxxx视频| 狠狠色狠狠色综合日日小说| 国产综合久久久久| 最新国产精品拍自在线播放| 国产精品com| 国内精品伊人久久| 97在线看免费观看视频在线观看| 九九精品在线播放| 国产精品第一页在线| 久久精品2019中文字幕| 国产精品白嫩美女在线观看| www.色综合| 中文字幕亚洲一区在线观看| 在线视频日本亚洲性| 久久成人这里只有精品| 欧美一区深夜视频| 3344国产精品免费看| 5566成人精品视频免费| 国内精品一区二区三区四区| 日韩a**站在线观看| 亚洲丁香久久久| 亚洲国产精品电影在线观看| 中文字幕日韩精品在线观看| 欧美在线视频播放| 久久久久国产精品免费网站| 亚洲人成啪啪网站| 欧美xxxx综合视频| 国产精品久久久久久久久粉嫩av| 国产精品电影网| 日日摸夜夜添一区| 欧美亚洲成人免费| 国产精品18久久久久久首页狼| 亚洲香蕉av在线一区二区三区| 国产成人精品在线视频| 91精品视频网站| 欧美一级淫片播放口| 日韩亚洲成人av在线| 色老头一区二区三区| 国产精品爱啪在线线免费观看| 欧美激情免费看| 国产免费一区二区三区在线能观看| 成人有码在线播放| 91亚洲精品一区| 69久久夜色精品国产7777| 国产精自产拍久久久久久| 久久人人爽人人爽人人片av高请| 国产精品视频999| 91日韩在线视频| 日韩女优人人人人射在线视频| 国产成人一区二区在线| 亚洲毛片在线免费观看| 久久久久久美女| 亚洲精品理论电影| 亚洲欧美日韩另类| www亚洲欧美| 亚洲国产又黄又爽女人高潮的| 国产成人免费av电影| 国产欧美精品一区二区三区-老狼| 国产欧美精品日韩精品| 欧美日韩国产丝袜另类| 中文字幕日韩欧美在线| 亚洲福利在线看| 中文字幕欧美日韩在线| 国产剧情久久久久久| 欧美激情成人在线视频| 国产精品美女无圣光视频| 久久视频这里只有精品| 亚洲欧美精品一区二区| 色多多国产成人永久免费网站| 久久伊人91精品综合网站| 国产日韩欧美综合| 亚洲天天在线日亚洲洲精| 亚洲成人久久网| 久久精品一偷一偷国产| 久热精品在线视频| 成人性教育视频在线观看| 日韩精品极品在线观看| 成人中文字幕+乱码+中文字幕| 欧洲成人免费aa| 色综合天天狠天天透天天伊人| 国产99久久精品一区二区 夜夜躁日日躁| 久久久999国产精品| 久久久国产精品免费| 日韩成人在线视频网站| 国产91精品久久久久久| 亚洲电影天堂av| 国产亚洲xxx| 97久久精品国产| 黄色成人在线免费| 国产日韩一区在线| 欧美日韩亚洲精品一区二区三区| 91色中文字幕| 亚洲欧美综合区自拍另类| 亚洲精品福利免费在线观看| 亚洲一品av免费观看| 成人免费视频在线观看超级碰| 精品久久久久久久久久久久久久| 欧美在线视频一二三| 亚洲精品乱码久久久久久金桔影视|