UI界面的一些简单控件
虽然都是代码 , 但是基本都有注释。
#import "ViewController.h" @interface ViewController () /**
* 创建视图
*/
@property(strong,nonatomic) UIView *myView;
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
/**
初始化视图
*/
self.myView=[[UIView alloc]initWithFrame:CGRectMake(0, 30, 200, 200)];
/**
* 背景色
*/
self.myView.backgroundColor=[UIColor colorWithRed:1.000 green:0.416 blue:0.882 alpha:1.000];
/**
* 添加子视图到view上
*/
[self.view addSubview:self.myView];
self.view.backgroundColor=[UIColor colorWithRed:0.330 green:1.000 blue:0.096 alpha:1.000];
CGRect rec=self.view.frame;
/**
* frame 相对父视图的坐标位置
*/
NSLog(@"view.frame:%@",NSStringFromCGRect(rec));
// bounds 只显示当前视图的大小 和位置无关(0,0)
NSLog(@"myView.bounds:%@",NSStringFromCGRect(self.myView.bounds));
// center 控件相对于父视图的中心点坐标
NSLog(@"%@",NSStringFromCGPoint(self.myView.center));
/**
* 设置视图的中心点坐标
*/
self.myView.center=CGPointMake(300, 350);
/**
* 改变视图的边界
*/
self.myView.bounds=CGRectMake(0, 0, 50, 50);
/**
* CGAffineTrans 让你在原有的视图上进行各种变换
*/
self.myView.transform=CGAffineTransformMakeTranslation(50, 0); } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; self.aview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
self.aview.backgroundColor=[UIColor colorWithRed:1.000 green:0.305 blue:0.259 alpha:1.000];
self.bview=[[UIView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
self.bview.backgroundColor=[UIColor blackColor];
self.cview=[[UIView alloc]initWithFrame:CGRectMake(200, 200, 200, 200)];
self.cview.backgroundColor=[UIColor colorWithRed:0.558 green:0.977 blue:0.584 alpha:1.000];
//添加子视图abc
[self.view addSubview:self.aview];
[self.view addSubview:self.bview];
[self.view addSubview:self.cview];
//插入指定视图 ,在XXX下面
[self.view insertSubview:self.bview belowSubview:self.aview];
//在XXX上面
[self.view insertSubview:self.bview aboveSubview:self.aview];
//在指定插入位置插入子视图
[self.view insertSubview:self.bview atIndex:2];
//在父视图中移除子视图
[self.bview removeFromSuperview];
//交换子视图的索引位置
[self.view exchangeSubviewAtIndex:2 withSubviewAtIndex:3];
//将子视图放在最后
[self.view sendSubviewToBack:self.cview];
//将子视图放在最前
[self.view bringSubviewToFront:self.aview]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
#import "ViewController.h" @interface ViewController ()
@property(strong,nonatomic) UILabel *labelName;
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
self.labelName=[[UILabel alloc]initWithFrame:CGRectMake(0, 100, 400, 200)];
self.labelName.backgroundColor=[UIColor redColor];
//输入文本
self.labelName.text=@"11135135135135135135";
//文本颜色
self.labelName.textColor=[UIColor blueColor];
//文本对齐方式(居中)
self.labelName.textAlignment=NSTextAlignmentCenter;
//文本字体放大或缩小
self.labelName.font=[UIFont systemFontOfSize:20 weight:20];
//显示行数
self.labelName.numberOfLines=10; [self.view addSubview:self.labelName]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
UI界面的一些简单控件的更多相关文章
- iOS开发UI篇—使用picker View控件完成一个简单的选餐应用
iOS开发UI篇—使用picker View控件完成一个简单的选餐应用 一.实现效果 说明:点击随机按钮,能够自动选取,下方数据自动刷新. 二.实现思路 1.picker view的有默认高度为162 ...
- 2013 duilib入门简明教程 -- 简单控件介绍 (12)
前面的教程应该让大家对duilib的整体有所映像了,下面就来介绍下duilib具体控件的使用. 由于官方没有提供默认的控件样式,所以我就尽量使用win7或者XP自带的按钮样式了,虽然界 ...
- WebForm--j简单控件、简单的登录(怎么链接数据库)
一.简单控件 1.label:边框(边框的颜色.样式.粗细) 是专门显示文字的, 被编译后是 <span id="Label1">Label</spa ...
- (转载)Android UI设计之AlertDialog弹窗控件
Android UI设计之AlertDialog弹窗控件 作者:qq_27630169 字体:[增加 减小] 类型:转载 时间:2016-08-18我要评论 这篇文章主要为大家详细介绍了Android ...
- duilib教程之duilib入门简明教程12.简单控件介绍
前面的教程应该让大家对duilib的整体有所映像了,下面就来介绍下duilib具体控件的使用. 由于官方没有提供默认的控件样式,所以我就尽量使用win7或者XP自带的按钮样式了,虽然界面比较土鳖 ...
- iOS开发UI篇—Quartz2D(自定义UIImageView控件)
iOS开发UI篇—Quartz2D(自定义UIImageView控件) 一.实现思路 Quartz2D最大的用途在于自定义View(自定义UI控件),当系统的View不能满足我们使用需求的时候,自定义 ...
- WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用
WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用 转自:http://www.cnblogs.com/wuhuacong/arch ...
- HTML5 Web app开发工具Kendo UI Web中Grid网格控件的使用
Kendo UI Web中的Grid控件不仅可以显示数据,并对数据提供了丰富的支持,包括分页.排序.分组.选择等,同时还有着大量的配置选项.使用Kendo DataSource组件,可以绑定到本地的J ...
- 【2017-05-18】WebForm的Repeater控件和一些简单控件
一.Repeater控件 1. <%@ %> - 这里面写一些声明和引用的 <% %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <% ...
随机推荐
- Scene视图辅助线绘制
有时候需要在Scene视图中绘制一些辅助线,方便进行一些编辑的工作,可以通过如下类和函数完成: 绘制辅助线,相关类: Gizmos类:用于在Scene视图中绘制调试信息或辅助线,这些辅助线只有在Sce ...
- ubuntu14.04编译安装Git2.7
在开源中国看文章, 随意之间, 在软件资讯栏看到git 2.7的信息. 一直在使用在git 1.9.1, 心中突感, 这个git 2.7是个什么东西, 怎么git的版本更新有如此快么. 印象里, 老外 ...
- Innodb Read IO 相关参数源代码解析
前言:最近在阅读Innodb IO相关部分的源代码.在阅读之前一直有个疑问,show global status 中有两个指标innodb_data_reads 和 innodb_data_read. ...
- Web前端面试题集锦
前端开发面试知识点大纲: 注意 转载须保留原文链接(http://www.cnblogs.com/wzhiq896/p/5927180.html )作者:wangwen896 HTML&CSS ...
- 软件工程——sprint 1回顾总结
主题:“我们在本次sprint中做了什么?接下来的打算?” sprint总结:在本次sprint里,这是我们团队的成员们第一次开始以团队的形式进行一次团队项目开发,早在第一次团队会议之时,我们便因团队 ...
- jQuery实现星星评分功能
一.这是我做的调查问卷中的一个功能.(第三方MVC框架) 二.功能说明:1.用户点击星星,将值放到隐藏域中.2.用户可以重新点击星星修改回答. 前台JS代码: <script type=&quo ...
- c# dynamic动态类型和匿名类
dynamic类型 简单示例 dynamic expando = new System.Dynamic.ExpandoObject(); //动态类型字段 可读可写 expando.Id = 1; e ...
- ACCESS作为网站数据库的弊端
现在网上绝大多数网站都是ACCESS+ASP的形式,因为ACCESS结构简单容易处理,而且也能满足多数的网站程序要求. ACCESS是小型数据库,既然是小型就有他根本的局限性,以下几种情况下数据库基本 ...
- Fluent NHibernate example
http://www.codeproject.com/Articles/26466/Dependency-Injection-using-Spring-NET http://stackoverflow ...
- Qt 框架 开发HTTP 服务器 开发记录
最近需求需要开发一款 HTTP ,然后由于先前接触过Qt,就直接用Qt写HTTP服务器了,也是为了当作练手,要不然是直接上HTTP框架的. 后端用C++ Qt框架 前端为了练手 当然是纯生的 js h ...