当前位置:网站首页>Swift Extension ChainLayout(UI的链式布局)(源码)
Swift Extension ChainLayout(UI的链式布局)(源码)
2022-06-24 06:55:00 【冯汉栩】
一直觉得自己写的不是技术,而是情怀,一个个的教程是自己这一路走来的痕迹。靠专业技能的成功是最具可复制性的,希望我的这条路能让你们少走弯路,希望我能帮你们抹去知识的蒙尘,希望我能帮你们理清知识的脉络,希望未来技术之巅上有你们也有我。
Swift Extension ChainLayout(UI的链式布局)(源码)地址
前言
当前这个swift的ui的链式布局的命名跟oc第三方NerdyUI的命名是一样的,这样两种语言切换去布局ui的时候就会很顺畅
这个封装用起来很好用的,使用习惯之后会觉得很爽。完全离开不了它
下面我一个一个控件的去介绍它的使用

正题
UIView

常用

移动view

将某个视图移到前面
setToFrontOf(_ superView: UIView)
移动前

调用方法后的效果
本来绿色view在蓝色view的上面,现在蓝色view在绿色view的上面

将某个视图移到后面
sendToBackOf(_ superView: UIView)
代码使用前的效果

方法执行后看下面的代码效果

获取view所在的VC
let vc = container.currentVc
print("vc: \(vc)")
vc: Optional(<SwiftDemol.ViewController: 0x7fa54390c700>)
切边角_1

.topLeft
.topRight
.bottomLeft
.bottomRight
.allCorners

切边角_2


View 截屏 针对 View | UIScrollView | WKWebView 等视图

隐藏键盘

view的frame值设置和获取
有些老一背的程序员喜欢用frame值约束控件
注意使用下面的方法设置或获取,约束控件的使用要用frame约束,不能用SnapKit约束然后又用frame获取x,y,是没有效果的
要用frame约束
不能用SnapKit约束
可以使用frame约束
还有比较小用的方法
/// 插入视图到某个层级
insertViewTo(_ superView: UIView, at index: Int)
/// 插入到某个视图下面
insertViewTo(_ superView: UIView, belowSubview siblingSubview: UIView)
/// 插入到某个视图上面
insertViewTo(_ superView: UIView, aboveSubview siblingSubview: UIView)
/// 交换视图层级
exchangeView(index1: Int, index2: Int)
UIButton

















边栏推荐
- The two most frequently asked locks in the interview
- SCM stm32f103rb, BLDC DC motor controller design, schematic diagram, source code and circuit scheme
- Pagoda panel installation php7.2 installation phalcon3.3.2
- Chapter 3 curve graph of canvas
- 软件工程导论——第二章——可行性研究
- 3-列表简介
- Bit operation
- Mousse shares listed on Shenzhen Stock Exchange: gross profit margin continued to decline, and marketing failed in the first quarter of 2022
- 【资料上新】迅为基于3568开发板的NPU开发资料全面升级
- 『C语言』系统日期&时间
猜你喜欢

Solve the problem of notebook keyboard disabling failure

The monthly salary of two years after graduation is 36K. It's not difficult to say

More than observation | Alibaba cloud observable suite officially released

Configure your own free Internet domain name with ngrok

第 1 篇:搭建OpenGL环境

Hilbert Huang Transform

Echart's experience (I): about y axis yaxis attribute

ImportError: cannot import name ‘process_ pdf‘ from ‘pdfminer. Pdfinterp 'error completely resolved

Moonwell Artemis现已上线Moonbeam Network

JDBC 在性能测试中的应用
随机推荐
从 jsonpath 和 xpath 到 SPL
Serialization of unity
使用 kubeconfig 文件组织集群访问
Timer usage notes
Part 1: building OpenGL environment
L1-019 谁先倒 (15 分)
毕业两年月薪36k,说难也不难吧
Coordinate transformation of graphic technology
某问答社区App x-zse-96签名分析
Notes on the use of date and time base
Pair class notes
交友相亲类软件是如何割你韭菜的
闲谈:3AC到底发生了什么?
L1-019 who goes first (15 points)
Basics of reptile B1 - scrapy (learning notes of station B)
Phonics
How does dating software cut your leeks
GraphMAE----論文快速閱讀
5-if语句(选择结构)
SCM stm32f103rb, BLDC DC motor controller design, schematic diagram, source code and circuit scheme