app
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let vc = ViewController()
let nav = UINavigationController(rootViewController: vc)
window?.rootViewController=nav
vc
class ViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
var Table : UITableView!
var Arr = NSArray()
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.barTintColor=UIColor.black
Arr = ["【ASMR】MTO同学的舔耳朵","【ASMR】专业的波兰妹子手淘沙大萨达","【ASMR】优质耳搔(无人声)","【ASMR】小萝莉洗头","【ASMR】小哥的d跑跑纸音","【ASMR】沙沙的舔耳音"]
Table=UITableView(frame: UIScreen.main.bounds)
Table.delegate=self
Table.dataSource=self
self.view.addSubview(Table)
let TableHeaderImg = UIImageView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 150))
TableHeaderImg.backgroundColor=UIColor.red
TableHeaderImg.image=UIImage(named: "1")
Table.tableHeaderView=TableHeaderImg
//126 110 183
let LeftBarBun = UIBarButtonItem(title: "ASMR", style: .done, target: self, action: nil)
self.navigationItem.leftBarButtonItem=LeftBarBun
LeftBarBun.tintColor=UIColor.init(red: 126/255.0, green: 110/255.0, blue: 183/255.0, alpha: 1.0)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 6
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 80
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "随机播放"
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell:UITableViewCell! = tableView.dequeueReusableCell(withIdentifier: "cell")
if cell == nil {
cell = UITableViewCell(style: .value1, reuseIdentifier: "cell")
cell.textLabel?.text=Arr[indexPath.row] as! String
}
cell.textLabel?.textColor=UIColor.white
cell.textLabel?.font=UIFont.systemFont(ofSize: 20)
cell.backgroundColor=UIColor.black
return cell
}
}