iOS swift 5 present从下面弹出一半 设置速度档位
ios 设置 swift 速度 下面 一半 present
2023-09-14 09:04:13 时间
文章目录
上半部分放一个半透明的View
代码
import UIKit
extension UIView {
//radius:切圆角的半径
//corner:要切四个角中的哪个角
func cornerCut(radius:Int,corner:UIRectCorner){
let maskPath = UIBezierPath.init(roundedRect: bounds, byRoundingCorners: corner, cornerRadii: CGSize.init(width: radius, height: radius))
let maskLayer = CAShapeLayer()
maskLayer.frame = bounds
maskLayer.path = maskPath.cgPath
layer.mask = maskLayer
}
}
class FDSpeedPresentVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
typealias SpeedClosure = (Int)->Void
var callBackClosure:SpeedClosure!
@IBOutlet var topView: UIView!
@IBOutlet var bottomView: UIView!
@IBOutlet var navigationBarMy: UINavigationBar!
@IBOutlet var tableView: UITableView!
override func viewDidLayoutSubviews() {
bottomView.cornerCut(radius: 10, corner: [.topLeft,.topRight])
}
override func viewDidLoad() {
super.viewDidLoad()
navigationBarMy.titleTextAttributes = [NSAttributedString.Key.font:UIFont(name: "PingFang SC", size: 18) as Any]
tableView.dataSource = self
tableView.delegate = self
let tap = UITapGestureRecognizer.init(target: self, action: #selector(tapView))
topView.addGestureRecognizer(tap)
}
@objc func tapView() {
dismiss(animated: true, completion: nil)
}
var selectedIndex = 0
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell:FDSpeedCell = tableView.dequeueReusableCell(withIdentifier: "FDSpeedCell", for: indexPath) as! FDSpeedCell
if indexPath.row == selectedIndex {
cell.btn.isSelected = true
}
switch indexPath.row {
case 0:
cell.label.text = "速度等级1"
case 1:
cell.label.text = "速度等级2"
case 2:
cell.label.text = "速度等级3"
default:
break
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
for cell in tableView.visibleCells {
let speedCell:FDSpeedCell = cell as! FDSpeedCell
speedCell.btn.isSelected = false
}
let selectedCell:FDSpeedCell = tableView.cellForRow(at: indexPath) as! FDSpeedCell
selectedCell.btn.isSelected = true
callBackClosure(indexPath.row)
dismiss(animated: true, completion: nil)
}
}
相关文章
- iOS小技能:设置tableView的点击事件优先级低于cell的选中事件
- 备份从android到ios系统文件,如何将音乐从安卓设备转移到iOS设备中「建议收藏」
- iOS证书(.p12)和描述文件(.mobileprovision)申请
- iOS锁屏时钟_ios时钟怎么调
- IOS – OpenGL ES 调节图像RGB通道 GPUImageRGBFilter
- IOS – OpenGL ES 设置图像 lookup 滤镜 GPUImageLookupFilter
- IOS – OpenGL ES 设置图像滤镜 GPUImageSoftEleganceFilter
- IOS – OpenGL ES 设置图像黑白噪点 GPUImageLocalBinaryPatternFilter
- 【iOS 开发】iOS 开发 简介 (IOS项目文件 | MVC 模式 | 事件响应机制 | Storyboard 控制界面 | 代码控制界面 | Retina 屏幕图片适配)
- iOS 自动循环播放广告控件实现详解手机开发
- iOS 设置app禁止横屏详解手机开发
- IOS设置UIView的边框为圆角详解手机开发
- iOS获取通讯录联系人信息详解手机开发
- iOS实现文件的写操作详解手机开发
- iOS从远程地址获取图片并修改尺寸详解手机开发
- iOS–自定义相册—对象数组按照时间戳排序详解手机开发
- ios基础:iOS改变状态栏字体颜色详解手机开发
- 把 Linux 安装到 iOS 设备上的步骤(ios安装linux)
- iOS让Oracle无处不在(ios支持oracle么)
- 谁说 iOS 就不适用Oracle(ios oracle软件)
- iOS系统下的Oracle数据库环境(ios oracle)
- iOS 15 Safari新变化:地址栏可根据用户偏好设置在顶部或底部
- IOS开发代码分享之设置UISearchBar的背景颜色