2017年3月19日 星期日

自訂TableViewCell


建立 TableViewController
建立 TableViewCell 類別,並將 ImageView 加入 TableViewCell
將 TableViewCell 加入 TableViewController
加入 textLabel & detailTextLabel
設定 textLabel & detailTextLabel 位置
將 ImageView 設為圓形




建立 TableViewController.swift

http://shihtsunghsin.blogspot.tw/2017/03/tableviewcontroller.html#more


建立 TableViewCell 類別


var myImageView = UIImageView()
建立 myImageView 變數

addSubView(myImageView)
將 myImageView 加入到 myCell

myImage.leftAnchor...................
設定 myImageView Layout


將 TableViewCell 加入 TableViewController


let cell = tableView.dequeueResuableCell(withIdentifier:"Cell" , for:indexPath) as! myCell
建立 cell 變數,並設定為 myCell

cell.imageView.image = UIImage("named:"001")
設定 myCell 的 myImageView成員


執行



加入 textLabel & detailTextLabel



執行




設定 textLabel & detailTextLabel 位置



執行




將 ImageView 設為圓形



執行







沒有留言:

張貼留言