当前位置: 首页 > news >正文

网站正在建设中 页面/关键词排名点击软件网站

网站正在建设中 页面,关键词排名点击软件网站,全国城建中心官网入口,嘉盛建设集团网站本文实例为大家分享了iOS模拟中奖名单循环滚动效果的具体代码,供大家参考,具体内容如下1.动态效果图:2.思路:(1)控件:一个父View,依次添加两个tableVew,使其上下紧挨着,高度均等于所…

本文实例为大家分享了iOS模拟中奖名单循环滚动效果的具体代码,供大家参考,具体内容如下

1.动态效果图:

c55b2e832dfbf130fb73bf3543f39d62.gif

2.思路:

(1)控件:一个父View,依次添加两个tableVew,使其上下紧挨着,高度均等于所有cell的总高度,且加载相同的的数据,父视图的clipsToBounds属性一定要设置为true

(2)滚动:使用计时器,调整时间及滚动大小,使展示平滑

(3)循环算法:当A列表滚动出界面时,就把它添加在B列表的下面,B列表滚动出界面时,就把它添加在A列表的下面,形成循环效果

3.Swift版核心代码(可直接复制粘贴看效果):

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

}

//返回行的个数

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{

return 10

}

//返回列的个数

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

}

//返回一个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{// 测试是否循环滚动

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()

}

}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

时间: 2019-09-07

http://www.lbrq.cn/news/807211.html

相关文章:

  • 私人网站怎么注册/营销策划公司名字
  • 网站建设如果登录失败/公司企业网站模板
  • 长春做企业网站/免费网站做seo
  • 用DW 做响应式网站/seo外链建设的方法
  • 做动效网站/成都网站seo收费标准
  • 设计logo网站 生成器/目前搜索引擎排名
  • pageadmin自助建站/网络优化公司哪家好
  • 衢州做网站的公司/搜索词排行榜
  • 国外b2b的代表平台有哪些/天门seo
  • 网站系统目前运行稳定/做网站怎么优化
  • 电子商务 网站建设/外贸平台排行榜前十名
  • 网站建设公司宝安/seo 页面链接优化
  • 小说网站开发的实际意义/seo工资
  • 网页制作工具可以发布网站吗/软文推广网站
  • 做搜索引擎的网站有哪些/怎么投稿各大媒体网站
  • 做的网站百度没收录/英国搜索引擎
  • word 添加 wordpress/佛山网站优化
  • wordpress pdf 打印/关键词排名优化顾问
  • 加盟装修公司怎么合作/成都seo达人
  • 深圳网络推广培训学校/seo教程培训班
  • 哪个网站可以做教师招聘题目/全网推广系统
  • 网站自动答题脚本怎么做/蒙牛牛奶推广软文
  • 网站开发手册下载/武汉搜索引擎营销
  • 基础建设图片/优化用户体验
  • 个人网站备案名字大全/友情链接
  • 有移动端网站 怎么做app/惠州seo全网营销
  • 哪家做网站公司/李守洪
  • 凤凰网新冠肺炎疫情实时动态/杭州企业seo
  • 做自己的首席安全官的网站/cms
  • 接做施工图的网站/百度站长联盟
  • 【最近公共祖先】ST表法
  • Flux.1系列模型解析--Flux.1
  • wpf之ContentPresenter
  • 分割回文串(回溯算法)
  • jQuery 最新语法大全详解(2025版)
  • vue怎么实现导入excel表功能