Objective-C-iOS UIScrollView UIPageControl 的用法详解
来源:互联网 发布:淘宝有客服电话 编辑:程序博客网 时间:2024/06/09 18:49
- (void)viewDidLoad {
[superviewDidLoad];
//UIView是视图类,所有的控件都直接或间接地继承它
//创建UIView
UIView *view1 = [[UIViewalloc] init];
UIView *view2 = [[UIViewalloc] initWithFrame:CGRectMake(20,120, 100,100)];
UIView *view3 = [[UIViewalloc] initWithFrame:CGRectMake(40,140, 100,100)];
//设置view的尺寸
view1.frame =CGRectMake(0,100, 100,100);
//设置view的背景色
view1.backgroundColor = [UIColorredColor];
view2.backgroundColor = [UIColorgreenColor];
view3.backgroundColor = [UIColorblueColor];
//设置view的中心位置,不改变view的大小
// view1.center = CGPointMake(80, 200);
//改变view的宽和高,视图原来的中心位置不变
// view1.bounds = CGRectMake(0, 0, 40, 40);
//设置view的tag值
view1.tag =1;
view2.tag =2;
view3.tag =3;
//依次添加三个视图(从上到下是:蓝,绿,红)
[self.viewaddSubview:view1];
[self.viewaddSubview:view2];
[self.viewaddSubview:view3];
//把view1(红)移到最上面
[self.viewbringSubviewToFront:view1];
//把view3(蓝)移到最下面
[self.viewsendSubviewToBack:view1];
//还有很多用来交换两个视图的方法,这里不再一一列举
/*
//交换两个视图的位置
// [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:2];
//把一个视图插在某个位置
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
//把一个视图插在另一个视图的下面
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
//把一个视图插在另一个视图的上面
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
//已经添加了某个视图
- (void)didAddSubview:(UIView *)subview;
//将要移除某个视图
- (void)willRemoveSubview:(UIView *)subview;
//把一个视图从一个父视图上移到另一个父视图上
- (void)willMoveToSuperview:(nullable UIView *)newSuperview;
//已经移动到了父视图上
- (void)didMoveToSuperview;
//把一个视图移动到一个窗口上
- (void)willMoveToWindow:(nullable UIWindow *)newWindow;
//已经移动到了一个窗口上
- (void)didMoveToWindow;
*/
//subViews中存放的(红,绿,蓝三个视图)
NSArray *subViews =self.view.subviews;
//如何找到一个视图,其实此时view4就是view1,view5也是view1
UIView *view4 = [subViewsobjectAtIndex:0];
view4.backgroundColor = [UIColorblackColor];
UIView *view5 = (UIView *)[self.viewviewWithTag:1];
view5.backgroundColor = [UIColorpurpleColor];
//隐藏view1
view1.hidden =YES;
//删除View2
[view2 removeFromSuperview];
//再添加一个视图
UIView *lastView = [[UIViewalloc] initWithFrame:CGRectMake(0,200, 200,200)];
lastView.backgroundColor = [UIColorcolorWithWhite:0.8alpha:1];
[self.viewaddSubview:lastView];
//设置view的透明度
lastView.alpha =0.5;
//设置lastView的圆角角度
lastView.layer.cornerRadius =10;
//设置边框的的宽度
lastView.layer.borderWidth =2;
//设置边框的颜色
lastView.layer.borderColor = [UIColorredColor].CGColor;
//允许剪切
lastView.clipsToBounds =YES;
}
- Objective-C-iOS UIScrollView UIPageControl 的用法详解
- Objective--C UIScrollView & UIPageControl 学习笔记
- IOS开发之UIScrollView与UIPageControl的用法
- iOS UIScrollView 和 UIPageControl的简单使用
- iOS中UIScrollView和UIPageControl的使用
- iOS --- UIScrollView和UIPageControl的简单使用
- IOS初级:UIScrollView & UIPageControl
- iOS开发 ----- UIScrollview UIPageControl
- iOS编程-------UIScrollView / UIPageControl
- IOS 之 UIScrollView,UIPageControl
- UIScrollView UIPageControl 的使用
- UIScrollView UIPageControl 的使用
- UIScrollView + UIPageControl的使用
- UIScrollView & UIPageControl 的创建
- UIScrollView&UIPageControl的使用
- UIScrollView&UIPageControl的使用
- IOS 导航页UIScrollView+UIPageControl
- iOS: UIScrollView的用法
- PHP的Socket网络编程入门指引
- 获取时间的方式
- Centos6下通过pssh并发执行命令
- Blind Java Deserialization - Part II - exploitation rev 2
- android studio中的Menu
- Objective-C-iOS UIScrollView UIPageControl 的用法详解
- lua math函数库
- materialdesign之tablayout的用法
- 无人驾驶车核心算法 — SLAM
- MongoDB的数据复制和数据切片
- 为web项目搭建sftp服务器
- 一些项目遇到的问题
- 取消应用程序崩溃后弹出的对话框
- 怎样将网络机顶盒usb调试模式打开