最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS模擬中獎名單循環(huán)滾動效果

 更新時(shí)間:2021年03月19日 15:32:54   作者:???smiling  
這篇文章主要為大家詳細(xì)介紹了iOS模擬中獎名單循環(huán)滾動效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了iOS模擬中獎名單循環(huán)滾動效果的具體代碼,供大家參考,具體內(nèi)容如下

1.動態(tài)效果圖:

 

2.思路:

(1)控件:一個(gè)父View,依次添加兩個(gè)tableVew,使其上下緊挨著,高度均等于所有cell的總高度,且加載相同的的數(shù)據(jù),父視圖的clipsToBounds屬性一定要設(shè)置為true

(2)滾動:使用計(jì)時(shí)器,調(diào)整時(shí)間及滾動大小,使展示平滑

(3)循環(huán)算法:當(dāng)A列表滾動出界面時(shí),就把它添加在B列表的下面,B列表滾動出界面時(shí),就把它添加在A列表的下面,形成循環(huán)效果

3.Swift版核心代碼(可直接復(fù)制粘貼看效果):

import UIKit

class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource{

 var tableView:UITableView!
 var doubleTableView:UITableView!
 let kScreenW = UIScreen.main.bounds.size.width
 let kXPercent = UIScreen.main.bounds.size.width / 375.0
 let kBorderW = CGFloat(15.0)
 let kYPercent = UIScreen.main.bounds.size.width / 375.0
 let cellId:String = "drawViewCell1"

 override func viewDidLoad() {
 super.viewDidLoad()


 self.addListTableView()
 }
 func addListTableView(){

 let tableWidth = kScreenW - kBorderW*3
 let tableBgView = UIView(frame: CGRect(x: (kScreenW-tableWidth)/2.0,y: 100*kYPercent,width: tableWidth,height: 148*kYPercent))
 tableBgView.clipsToBounds = true
 tableBgView.backgroundColor = UIColor.yellow
 self.view.addSubview(tableBgView)

 //

 tableView = UITableView(frame: CGRect(x: 0,y: 0,width: tableWidth,height: 148*kYPercent*2), style: UITableViewStyle.plain)
 tableView.backgroundColor = UIColor.clear
 tableView.delegate = self
 tableView.dataSource = self
 tableView.separatorStyle = UITableViewCellSeparatorStyle.none
 tableBgView.addSubview(tableView)


 doubleTableView = UITableView(frame: CGRect(x: 0,y: tableView.frame.origin.y+tableView.frame.size.height,width: tableWidth,height: 148*kYPercent*2), style: UITableViewStyle.plain)
 doubleTableView.backgroundColor = UIColor.clear
 doubleTableView.delegate = self
 doubleTableView.dataSource = self
 doubleTableView.separatorStyle = UITableViewCellSeparatorStyle.none
 tableBgView.addSubview(doubleTableView)

 //
 Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(personListScroll(timer:)), userInfo: nil, repeats: true)
 }
 @objc func personListScroll(timer:Timer){

 // 1>移動tableView的frame
 var newTableViewframe = self.tableView.frame
 newTableViewframe.origin.y -= 2*kYPercent
 if (newTableViewframe.origin.y < -(doubleTableView.frame.size.height)) {

  newTableViewframe.origin.y = tableView.frame.size.height
 }
 self.tableView.frame = newTableViewframe

 // 2>移動doubleTableView的frame
 var newDoubleViewframe = self.doubleTableView.frame
 newDoubleViewframe.origin.y -= 2*kYPercent
 if newDoubleViewframe.origin.y < -(tableView.frame.size.height) {

  newDoubleViewframe.origin.y = tableView.frame.size.height
 }
 self.doubleTableView.frame = newDoubleViewframe

 }

 //返回行的個(gè)數(shù)
 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
 return 10
 }
 //返回列的個(gè)數(shù)
 func numberOfSections(in tableView: UITableView) -> Int {
 return 1;
 }
 //去除頭部空白
 func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
 return 0.001
 }
 //去除尾部空白
 func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
 return 0.001
 }
 //返回一個(gè)cell
 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{

 //回收池
 var cell:UITableViewCell! = tableView.dequeueReusableCell(withIdentifier: cellId)

 if cell == nil{//判斷是否為nil

  cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: cellId)
 }
 cell.backgroundColor = UIColor.clear
 cell.selectionStyle = UITableViewCellSelectionStyle.none

 if tableView == self.tableView{// 測試是否循環(huán)滾動

  cell.textLabel?.text = "張先生"
 }else {

  cell.textLabel?.text = "李小姐"
 }

 return cell
 }
 //返回cell的高度
 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat{

 return 148/5.0*kYPercent
 }


 override func didReceiveMemoryWarning() {
 super.didReceiveMemoryWarning()

 }


}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • iOS 微信分享功能簡單實(shí)現(xiàn)

    iOS 微信分享功能簡單實(shí)現(xiàn)

    本文介紹了iOS 微信分享功能的實(shí)現(xiàn)步驟與方法,具有一定的參考作用。下面跟著小編一起來看下吧
    2017-01-01
  • iOS tableview實(shí)現(xiàn)簡單搜索功能

    iOS tableview實(shí)現(xiàn)簡單搜索功能

    這篇文章主要為大家詳細(xì)介紹了iOS tableview實(shí)現(xiàn)簡單搜索功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • IOS倒計(jì)時(shí)設(shè)置UIButton標(biāo)題title的抖動問題

    IOS倒計(jì)時(shí)設(shè)置UIButton標(biāo)題title的抖動問題

    這篇文章主要介紹了IOS倒計(jì)時(shí)設(shè)置UIButton標(biāo)題title的抖動問題,在發(fā)送驗(yàn)證碼后,button狀態(tài)需要變?yōu)閐isable,每隔一秒顯示倒計(jì)時(shí)時(shí)間,下面通過本文給大家介紹設(shè)置方法,一起看看吧
    2016-12-12
  • IOS 靜態(tài)庫和Framework區(qū)別

    IOS 靜態(tài)庫和Framework區(qū)別

    這篇文章主要介紹了IOS 靜態(tài)庫和Framework區(qū)別的相關(guān)資料,這里對動態(tài)庫與靜態(tài)庫做比較,選擇什么時(shí)候使用庫文件,需要的朋友可以參考下
    2016-12-12
  • iOS AFNetworking各種功能封裝類代碼

    iOS AFNetworking各種功能封裝類代碼

    下面小編就為大家分享一篇iOS AFNetworking各種功能封裝類代碼,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • 阿里數(shù)據(jù)iOS端啟動速度優(yōu)化心得

    阿里數(shù)據(jù)iOS端啟動速度優(yōu)化心得

    本篇文章給大家詳細(xì)分析了阿里數(shù)據(jù)iOS端啟動速度優(yōu)化的知識點(diǎn)以及心得,對此有興趣的朋友參考學(xué)習(xí)下吧。
    2018-02-02
  • IOS代碼筆記之下拉菜單效果

    IOS代碼筆記之下拉菜單效果

    這篇文章主要為大家詳細(xì)介紹了IOS實(shí)現(xiàn)下拉菜單效果的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-07-07
  • iOS10 ATS 配置詳細(xì)介紹

    iOS10 ATS 配置詳細(xì)介紹

    這篇文章主要介紹了iOS10 ATS 配置詳細(xì)介紹的相關(guān)資料,這里舉例說明該如何配置,需要的朋友可以參考下
    2016-12-12
  • iOS中最全的各種定時(shí)器使用教程

    iOS中最全的各種定時(shí)器使用教程

    這篇文章主要給大家介紹了關(guān)于iOS中最全的各種定時(shí)器的使用教程,文中通過示例代碼介紹的非常詳細(xì),通過文中介紹的最全的定時(shí)器相信會對各位iOS開發(fā)者們帶來一定的幫助,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-09-09
  • iOS消息發(fā)送和轉(zhuǎn)發(fā)示例詳解

    iOS消息發(fā)送和轉(zhuǎn)發(fā)示例詳解

    這篇文章主要給大家介紹了關(guān)于iOS消息發(fā)送和轉(zhuǎn)發(fā)的相關(guān)資料,用Objective-C的術(shù)語來講,這叫做“給某個(gè)對象發(fā)送某條消息”。文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2018-03-03

最新評論

喜德县| 永新县| 巧家县| 阳西县| 房产| 贵南县| 河北区| 攀枝花市| 永兴县| 井研县| 昭觉县| 大关县| 葫芦岛市| 茌平县| 旺苍县| 南丰县| 读书| 名山县| 合水县| 海伦市| 肃北| 观塘区| 嵩明县| 江城| 凤庆县| 张北县| 鄯善县| 收藏| 梅州市| 沾化县| 洪湖市| 兴化市| 龙胜| 获嘉县| 同江市| 洛南县| 黄冈市| 江城| 合作市| 喀喇| 通道|