首页 技术 正文
技术 2022年11月14日
0 收藏 394 点赞 3,150 浏览 1890 个字
         //创建View
let view1 =UIView()
let view2 =UIView(frame: CGRectMake(,, ,))
let view3 =UIView(frame: CGRectMake(,, ,)) //设置view的尺寸
view1.frame =CGRectMake(,, ,) //设置view的背景色
view1.backgroundColor =UIColor.redColor()
view2.backgroundColor =UIColor.greenColor()
view3.backgroundColor = UIColor.blueColor() //设置view的中心位置,不改变view的大小
view1.center =CGPointMake(,) //改变view的宽和高,视图原来的中心位置不变
view1.bounds =CGRectMake(,, ,); //设置view的tag值
view1.tag =;
view2.tag =;
view3.tag =; //依次添加三个视图(从上到下是:蓝,绿,红)
self.view.addSubview(view1)
self.view.addSubview(view2)
self.view.addSubview(view3) //把view1(红)移到最上面
self.view.bringSubviewToFront(view1) //把view3(蓝)移到最下面
self.view.sendSubviewToBack(view3) //交换两个视图的位置
self.view.exchangeSubviewAtIndex(, withSubviewAtIndex: ) //把一个视图插在某个位置
self.view.insertSubview(view1, atIndex:) //把一个视图插在另一个视图的下面
self.view.insertSubview(view1, belowSubview: view3) //把一个视图插在另一个视图的上面
self.view.insertSubview(view1, aboveSubview: view2) //已经添加了某个视图
self.view.didAddSubview(view1) //将要移除某个视图
self.view.willRemoveSubview(view1) //把一个视图从一个父视图上移到另一个父视图上
self.view.willMoveToSuperview(view3) //已经移动到了父视图上
self.view.didMoveToSuperview() //把一个视图移动到一个窗口上
self.view.willMoveToWindow(UIApplication.sharedApplication().keyWindow) //已经移动到了一个窗口上
self.view.didMoveToWindow() //subViews中存放的(红,绿,蓝三个视图)
let subViews :NSArray = NSArray.init(array:self.view.subviews) //如何找到一个视图,其实此时view4就是view1,view5也是view1
let view4 = subViews.objectAtIndex()as! UIView
view4.backgroundColor =UIColor.blackColor()
let view5 =self.view.viewWithTag()
view5?.backgroundColor =UIColor.purpleColor() //隐藏view1
view1.hidden =true; //删除View2
view2.removeFromSuperview() //再添加一个视图
let lastView =UIView()
lastView.frame =CGRectMake(,, ,);
lastView.backgroundColor =UIColor.init(white:0.80, alpha: )
self.view.addSubview(lastView) //设置view的透明度
lastView.alpha =0.5 //设置lastView的圆角角度
lastView.layer.cornerRadius =
//设置边框的的宽度
lastView.layer.borderWidth =
//设置边框的颜色
lastView.layer.borderColor =UIColor.redColor().CGColor
//允许剪切
lastView.clipsToBounds =true
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,496
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,909
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,743
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,496
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,134
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,298