欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

ios如何實現(xiàn)tableView頂部彈簧圖片效果

這篇文章主要介紹ios如何實現(xiàn)tableView頂部彈簧圖片效果,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

十年的嵐皋網站建設經驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。營銷型網站建設的優(yōu)勢是能夠根據(jù)用戶設備顯示端的尺寸不同,自動調整嵐皋建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)公司從事“嵐皋網站設計”,“嵐皋網站推廣”以來,每個客戶項目都認真落實執(zhí)行。

一種思路是將圖片放置tableView的tableHeaderView上當tablview下移改變圖片的frame達到效果。當然這個效果特別簡單,高手可以略過。

代碼如下

import UIKit

class ViewController: UIViewController,UITableViewDataSource,UITableViewDelegate {

 lazy var myTableView : UITableView! = {
  var tableView = UITableView.init(frame: self.view.frame,style:UITableViewStyle.plain)
  tableView.delegate = self
  tableView.dataSource = self
  tableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: "mycell")
  return tableView
 }()
 
 var headerImageView:UIImageView?
 var headerView:UIView?
 var headerViewHeight:CGFloat = 0.0
 
 
 override func viewDidLoad() {
  super.viewDidLoad()
  // Do any additional setup after loading the view, typically from a nib.
  setupUI()
 }

 func setupUI(){
  headerView = UIView.init(frame: CGRect(x:0,y:0,width:self.view.frame.width,height:300))
  headerViewHeight = headerView!.frame.height;
  self.view.addSubview(headerView!)
  headerImageView = UIImageView.init(frame: headerView!.frame)
  headerImageView?.image = UIImage.init(named: "bg-mine")
  headerView?.addSubview(headerImageView!)
  myTableView.tableHeaderView = headerView
  self.view.addSubview(myTableView)
  
 }
 

 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  return 2
 }
 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  let cell:UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "mycell", for: indexPath)
  cell.textLabel?.text = "測試"
  return cell
 }
 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  return 50
 }
 
 func scrollViewDidScroll(_ scrollView: UIScrollView) {
  let contentOffSetY = scrollView.contentOffset.y
  if contentOffSetY < 0 {
   var rect = headerView?.frame
   rect?.size.height = headerViewHeight - contentOffSetY
   let headerViewWidth = headerView?.frame.size.width
   rect?.size.width = headerViewWidth!*(headerViewHeight-contentOffSetY)/headerViewHeight
   rect?.origin.x = -((rect?.size.width)! - headerViewWidth!)/2
   rect?.origin.y = contentOffSetY
   headerView?.frame = rect!
   headerImageView?.frame = rect!
  } 
 }
}

以上是“ios如何實現(xiàn)tableView頂部彈簧圖片效果”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網站名稱:ios如何實現(xiàn)tableView頂部彈簧圖片效果
文章網址:http://chinadenli.net/article12/ppdjdc.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供營銷型網站建設網站內鏈網站排名靜態(tài)網站關鍵詞優(yōu)化網站設計公司

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網站建設