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

服装网站建设公司哪家好自己可以做网站空间吗

服装网站建设公司哪家好,自己可以做网站空间吗,自助建站系统怎么用,国家企业注册信息查询UI学习#xff08;一#xff09; UILabelUIButtonUIButton事件 UIViewUIView对象的隐藏UIView的层级关系 UIWindowUIViewController定时器与视图对象 UISwitch UILabel UILabel是一种可以显示在屏幕上#xff0c;显示文字的一种UI。 下面使用代码来演示UILabel的功能#… UI学习一 UILabelUIButtonUIButton事件 UIViewUIView对象的隐藏UIView的层级关系 UIWindowUIViewController定时器与视图对象 UISwitch UILabel UILabel是一种可以显示在屏幕上显示文字的一种UI。 下面使用代码来演示UILabel的功能 implementation ViewController- (void)createUI {UILabel* label [[UILabel alloc] init];//显示的文字label.text 燕子没有你我怎么活啊;//label显示的位置label.frame CGRectMake(10, 300, 350, 200);//label的背景颜色label.backgroundColor [UIColor greenColor];//整个屏幕的背景颜色self.view.backgroundColor [UIColor redColor];//将label显示在屏幕上[self.view addSubview:label];//label中文字的大小标准大小34label.font [UIFont systemFontOfSize:34];//label中文字阴影的颜色label.shadowColor [UIColor grayColor];//阴影的偏移位置label.shadowOffset CGSizeMake(3, 0);//label中文字显示的行数当等于0时系统自行判断显示多少行合适label.numberOfLines 0;//label中文字的颜色label.textColor [UIColor whiteColor];//默认文字在label中靠左显示这里将文字改为在label中间显示label.textAlignment NSTextAlignmentCenter;}- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.[self createUI]; }end CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)返回了一个结构体CGRectGRect结构在屏幕上定义了一个矩形它包含和大小。 它是用来定义一个矩形的CGFloat x是对应屏幕的横向x坐标 CGFloat y对应就是纵向y坐标。这里注意一点描点是从屏幕的左上方开始的。 NSTextAlignmentLeft/Center/Right :文字靠左、居中、靠右。 效果图 UIButton implementation ViewController-(void) createUIRectButton {UIButton* btn [UIButton buttonWithType:UIButtonTypeRoundedRect];btn.frame CGRectMake(20, 300, 300, 50);btn.backgroundColor [UIColor greenColor];//向按钮普通状态添加文字[btn setTitle:按钮01 forState:UIControlStateNormal];//向按钮高亮状态提供文字[btn setTitle:按钮01已按下 forState:UIControlStateHighlighted];//设置按钮文字普通状态的颜色[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];//设置按钮高亮状态文字的颜色[btn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];//设置文字的字体大小btn.titleLabel.font [UIFont systemFontOfSize:24];//下面又定义了一个按钮UIButton* btn2 [UIButton buttonWithType:UIButtonTypeRoundedRect];btn2.frame CGRectMake(50, 150, 300, 50);btn2.backgroundColor [UIColor brownColor];[btn2 setTitle:按钮02 forState:UIControlStateNormal];[btn2 setTitle:按钮02已按下 forState:UIControlStateHighlighted];[btn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];[btn2 setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];btn2.titleLabel.font [UIFont systemFontOfSize:24];btn.tag 123;btn2.tag 321;//UIButton事件[btn addTarget:self action:selector(action01:) forControlEvents:UIControlEventTouchUpInside];[btn2 addTarget:self action:selector(action01:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn];[self.view addSubview:btn2] }-(void)action01:(UIButton*) btn {if(btn.tag 123){NSLog(玛卡巴卡);} else if(btn.tag 321){NSLog(汤姆布利波);} }-(void)creatBtn {UIButton* btnp [UIButton buttonWithType:UIButtonTypeCustom];//UIButton* btno1 [UIButton buttonWithType:UIButtonTypeCustom];btnp.frame CGRectMake(20, 400, 400, 400);//加载两张图片imageNamed后是图片名要加图片类型UIImage* ima1 [UIImage imageNamed:im1.jpg];UIImage* ima2 [UIImage imageNamed:im2.jpg];//为图片按钮设置当状态不同呈现的图片[btnp setImage:ima1 forState:UIControlStateNormal];[btnp setImage:ima2 forState:UIControlStateHighlighted];[self.view addSubview:btnp];//UIButton事件[btn addTarget:self action:selector(action01:) forControlEvents:UIControlEventTouchUpInside];}-(void) action02 {NSLog(Dont fukin touch it); }- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.[self createUIRectButton];[self creatBtn]; }end 效果图 UIButton事件结果 UIButton事件 addTarget:selfaction:selector(action02)forControlEvents:UIControlEventTouchUpInside]:向按钮添加事件的函数当函数满足第三处要求时执行第二处的方法。UIControlEventTouchUplnside当目标在控件内部结束触摸屏幕并松开时在按钮范围内会触发该事件。UIControlEventTouchUpOutside当目标在控件内部结束触摸屏幕并松开时在按钮范围外结束会触发该事件。UIControlEventTouchDown当目标在控件内部开始触摸屏幕按钮时触发该事件。可以一个事件控制几个按钮例如程序中的玛卡巴卡和汤姆布利波这里为了区分两个按钮使用btn.tag区分两个按钮也可以一个按钮触发多个事件。 UIView UIView 是iOS的视图对象是所有显示在屏幕上的基础类。所有显示在屏幕上的对象都继承于UIViewUIView有背景颜色矩形对象有层级关系 示例程序 implementation ViewController-(void) create {//创建一个UIView对象UIView* view [[UIView alloc] init];view.frame CGRectMake(80, 200, 100, 100);view.backgroundColor [UIColor redColor];//将视图做为父视图的子视图管理起来[self.view addSubview:view];//view1.backgroundColor [UIColor greenColor];//[self.view addSubview:view1]; }- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.[self create]; }end效果图 UIView对象的隐藏 view.hidden NO;//YES即为隐藏视图NO反之view1.alpha .5;//透明度1为完全不透明0为完全透明view.opaque NO;//设置是否显示不透明[view1 removeFromSuperview];//上面是四种隐藏UIView对象的方法 hiddenYES时即为隐藏视图NO反之默认为NO。alpha 设置透明度1为完全不透明0为完全透明半透明时会显示父类对象的底色。removeSuperview将自己从父类视图的管理中删除掉也就不会显示在屏幕上 UIView的层级关系 示范程序 implementation ViewController-(void) create {UIView* view [[UIView alloc] init];view.frame CGRectMake(100, 100, 100, 100);view.backgroundColor [UIColor redColor];UIView* view1 [[UIView alloc] init];view1.frame CGRectMake(125, 125, 100, 100);view1.backgroundColor [UIColor greenColor];UIView* view2 [[UIView alloc] init];view2.frame CGRectMake(150, 150, 100, 100);view2.backgroundColor [UIColor blueColor];//谁先被添加谁先绘制[self.view addSubview:view];[self.view addSubview:view1];[self.view addSubview:view2];//将某一个视图调整到最前面来[self.view bringSubviewToFront:view];//把某一个调整到最后[self.view sendSubviewToBack:view];//subviews是管理self.view的子视图的数组UIView* viewfront self.view.subviews[2];UIView* viewback self.view.subviews[0];if(viewfront view2) {NSLog(相等);} }- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.[self create]; }当层级重叠时谁先被添加就先绘制谁bringSubviewToFront:把某个层级移动最上层。sendSubviewToBack把某个层级移到最下层。subviews管理self.view的子视图的数组。 运行结果 UIWindow 注意 老版本UIWindow的代码是写在“AppDelegate.m”中的。但是现在都不在这里写了现在写到SceneDelegate.m里面而且UIWindow对象不需要你手动创建了。 一个UIWindow对象为应用程序的用户界面提供了背景以及重要的事件处理行为。 UIWindow继承自UIView每一个view想要出现在屏幕上都依赖于window但是程序中的window之间是相互独立的。应用程序收到事件之后会先转发给适当的window对象从而又将事件转发给view对象。 具体来说UIWindow有以下几个主要功能 视图层次结构视图: UIWindow是应用程序的层次结构视图其整体视图是附属于UIWindow子视图。 当应用程序启动时系统会自动创建一个UIWindow实例并将其设置为应用程序的主窗口。接收和分发事件 UIWindow负责接收来自用户的输入事件例如触摸事件、按键事件等。 UIWindow会根据视图层次结构将这些事件分配给合适的视图进行处理。管理视图控制器: UIWindow可以持有一个根基健全的模型特别是一个UIViewController实例。多窗口支持 特定特殊场景下例如iPad的分屏应用程序可以创建多个UIWindow实例。 每个UIWindow都有自己的视点层次结构,相互独立。状态栏管理: UIWindow负责管理应用程序的状态栏例如电池电量、网络信号等图标的显示。 示例代码 - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {//创建一个视图跟踪器作为UIWindow的根视控制器self.window.rootViewController [[UIViewController alloc] init];//设置window的颜色self.window.backgroundColor [UIColor blueColor];//将window有效的显示在屏幕上[self.window makeKeyAndVisible];//直接给UIWindow上添加视图UIView* view [[UIView alloc] initWithFrame:CGRectMake(100, 200, 50, 50)];view.backgroundColor [UIColor greenColor];UIView* backview [[UIView alloc] initWithFrame:CGRectMake(50, 200, 300, 300)];backview.backgroundColor [UIColor redColor];[self.window addSubview:backview];//子视图的坐标会随着父视图的坐标改变而改变[backview addSubview:view];//打印不同对象的window属性可以看出他们是同一个windowNSLog(%, view.window);NSLog(%, backview.window);NSLog(%, self.window); }打印结果 效果图 UIViewController UIViewController是一个视图控制器在整个UIKit中只有一个根视图控制器属于window的属性。视图控制器用来管理界面和处理界面的逻辑类对象程序启动前必须对根视图控制器赋值。 先新建一个View02类 #import View02.hinterface View02 ()endimplementation View02- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.//给视图控制器设置背景颜色self.view.backgroundColor [UIColor greenColor]; }- (void) touchesBegan:(NSSetUITouch * *)touches withEvent:(UIEvent *)event {//使当前的控制器消失掉传入两个参数//第一个参数指是否有动画效果//第二个参数指结束后是否调用block块操作不需要为nil[self dismissViewControllerAnimated: YES completion: nil]; }/* #pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {// Get the new view controller using [segue destinationViewController].// Pass the selected object to the new view controller. } */end #import ViewController.h #import View02.hinterface ViewController ()endimplementation ViewController-(void)touchesBegan:(NSSetUITouch * *)touches withEvent:(UIEvent *)event {//创建视图控制器二View02* vc [[View02 alloc] init];//显示一个新的视图控制器界面到屏幕上来//第一个参数新的视图控制器//第二个参数是否是用动画切换效果//第三个参数切换后是否使用block块不使用为nil[self presentViewController:vc animated:YES completion:nil]; }//当视图控制器第一次被加载视图时调用此函数。 //当布局初始化视图来使用。 - (void)viewDidLoad {//默认情况下调用父类的加载视图函数[super viewDidLoad];// Do any additional setup after loading the view.UIView* view [[UIView alloc] init];view.backgroundColor [UIColor greenColor];view.frame CGRectMake(100, 100, 100, 200);self.view.backgroundColor [UIColor redColor];[self.view addSubview:view]; } //视图即将显示调用此函数 //参数表示是否用动画切换后消失 //当前的状态视图还没有显示 -(void) viewWillAppear:(BOOL)animated {NSLog(即将显示); }//视图即将消失调用此函数 //参数表示是否用动画切换后消失 //当前的状态视图还是在屏幕上 -(void) viewWillDisappear:(BOOL)animated {NSLog(即将消失); }-(void) viewDidAppear:(BOOL)animated {NSLog(已经显示); }-(void) viewDidDisappear:(BOOL)animated {NSLog(已经消失); }end 效果图 点击后效果图 定时器与视图对象 定时器对象 可以在每个固定时间发送一个消息通过此函数可在固定时间段来完成一个根据时间间隔的任务通过此消息来调用相应的时间函数 接口部分 #import UIKit/UIKit.hinterface ViewController : UIViewController {//定义一个定时器对象//可以在每个固定时间发送一个消息//通过此消息来调用相应的时间函数//通过此函数可在固定时间段来完成一个根据时间间隔的任务NSTimer* _timerView; }property (retain, nonatomic) NSTimer* timerView; end实现部分 #import ViewController.hinterface ViewController ()endimplementation ViewController //属性和成员变量的同步 synthesize timerView _timerView;- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.//启动定时器按钮UIButton* btn [UIButton buttonWithType:UIButtonTypeRoundedRect];btn.frame CGRectMake(100, 100, 80, 40);[btn setTitle:启动定时器 forState:UIControlStateNormal];[btn addTarget:self action:selector(pressStart) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn];//停止定时器按钮UIButton* btnstop [UIButton buttonWithType:UIButtonTypeRoundedRect];btnstop.frame CGRectMake(100, 200, 80, 40);[btnstop setTitle:停止定时器 forState:UIControlStateNormal];[btnstop addTarget:self action:selector(pressStop) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btnstop];UIView* view [[UIView alloc] init];view.backgroundColor [UIColor greenColor];view.frame CGRectMake(0, 0, 80, 80);[self.view addSubview:view];//设置view的标签值//通过父亲视图对象以及view的标签值可以获得相应的视图对象view.tag 111;} -(void) pressStart {//NSTtimer类方法创建一个定时器并且启动这个定时器//P1:每隔多久调用定时器函数以秒数为单位的整数调用第三个参数//P2:表示实现定时器函数的对象指针//P3:定时器函数对象//P4:可以传入定时器函数中一个参数无参数可以传nil//P5:定时器是否重复操作YES为重复NO为只完成一次函数调用//返回值为一个新建好的定时器对象_timerView [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:selector(updateTimer:) userInfo:美羊羊 repeats:YES];}//定时器函数 //可以将定时器本身做为参数传入 -(void) updateTimer:(NSTimer*) timer {NSLog(开始啦,%, timer.userInfo);UIView* view [self.view viewWithTag:111];view.frame CGRectMake(view.frame.origin.x 1, view.frame.origin.y 1, 80, 80); }-(void) pressStop {if(_timerView ! nil) {[_timerView invalidate];}//[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:selector(stop) userInfo:nil repeats:NO];//NSLog(停止啦); }-(void) stop {NSLog(停止啦); }end 效果图 UISwitch UISwitch是一个开关控件有开、关两种状态可以切换是定义在UIKit库中的一个控件苹果官方的控件都定义在UIKit框架中且UIKit框架中的所有控件都以UI开头 interface ViewController : UIViewController {//定义一个开关控件//可以进行状态的改变//开关两种状态可以进行切换//所有UIKit框架库中的控件均以UI开头//苹果官方的控件都定义在UIKit框架中UISwitch* _myswitch; }property (retain, nonatomic) UISwitch* myswitch;end implementation ViewController //同步属性和成员变量 synthesize myswitch _myswitch; - (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.//创建一个开关对象//继承与UIView_myswitch [[UISwitch alloc] init];//苹果官方的控件的位置设置//位置XY的值可以改变宽度和高度无法改变_myswitch.frame CGRectMake(100, 200, 80, 40);//_myswitch.backgroundColor [UIColor blueColor];//开关状态设置属性//YES开启状态NO关闭状态_myswitch.on YES;//也可以使用set函数//[_myswitch setOn:YES];//设置开关状态//P1:状态设置//P2:是否开启动画效果[_myswitch setOn:YES animated:YES];[self.view addSubview:_myswitch];//设置开启状态的风格颜色[_myswitch setOnTintColor:[UIColor redColor] ];//改变开关按钮的颜色[_myswitch setThumbTintColor:[UIColor blueColor]];//设置整体风格颜色//[_myswitch setTintColor:[UIColor purpleColor]];//向开关控件添加事件函数//每次改变的时候都会调用swChange函数[_myswitch addTarget:self action:selector(swChange:) forControlEvents:UIControlEventValueChanged];//self.view.backgroundColor [UIColor blueColor]; }-(void) swChange:(UISwitch*) sw {if(sw.on YES)NSLog(开关被打开);elseNSLog(开关被关上); }end 效果图
http://www.w-s-a.com/news/305016/

相关文章:

  • 重庆网站seo公司哪家好超级优化大师
  • 成都网站建设推广详情邵阳市住房和城乡建设局网站
  • 淄博网站推广猎头公司有哪些
  • 局域网内建立网站90设计网怎么样
  • 域名备案和网站备案有什么不同工程项目建设网站
  • 做网站难吗?wordpress评论qq
  • 权威网站优化价格电子商务静态网站建设实验报告
  • 公司如何办网站北京网站建设公司内江
  • 六安建设网站企业营业执照查询系统入口
  • a5网站建设如果建设淘宝导购网站
  • html5响应式网站开发教程在国内做跨境电商怎么上外国网站
  • win7配置不能运行wordpress关键词快速优化排名软件
  • 餐饮公司最好的网站建设手机网站 搜索优化 百度
  • 17网站一起做网批做服装团购网站
  • 广州网站制作知名企业网站搭建品牌
  • 如何去除网站外链个人网页制作全过程
  • 保洁公司网站怎么做科技设计网站有哪些内容
  • 建设厅网站查询网页设计好就业吗
  • 惠东县网站建设wordpress 如何回到初始
  • 如何让公司网站网站转备案
  • 获得网站所有关键字北京网站建设116net
  • 铜陵电子商务网站建设做龙之向导网站有用吗
  • 购物网站制作费用沧州新华区
  • 信宜网站设计公司在线购物商城系统
  • 网站维护是什么样如何制作网站教程视频讲解
  • 网站建设网络推广代理公司wordpress图片防盗链
  • 网站备案关站沈阳男科医院哪家好点
  • 王者荣耀网站建设的步骤网站页面用什么软件做
  • 典型网站开发的流程房屋装修效果图三室一厅
  • 制作微网站多少钱阿里巴巴做网站的电话号码