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#代码的 <%= %> - 往界面上输出一个变量的值 <% ...
随机推荐
- http协议客户端向服务器端请求时一般需要发送的内容
out.println("GET /shopping/index.html HTTP/1.1");//请求行 包括请求方式,文件路径, http协议版本(必写)请求头.... ou ...
- WCF小白初试 错误之一:“有零个应用程序终结点”的解决办法
遇到这类问题 应该是配置文件出现了问题 解决办法是将配置文件中的<service name="命名空间+类名">就可以解决
- 直接拿来用!最火的Android开源项目
GitHub在中国的火爆程度无需多言,越来越多的开源项目迁移到GitHub平台上.更何况,基于不要重复造轮子的原则,了解当下比较流行的Android与iOS开源项目很是必要.利用这些项目,有时能够让你 ...
- The Top 10 Javascript MVC Frameworks Reviewed
Over the last several months I have been in a constant search for the perfect javascript MVC framewo ...
- AEAI BPM流程集成平台V3.0.2版本开源发布
本次开源发布的是AEAI BPMV3.0.2版流程平台,该版本是数通畅联首次正式对外发布的版本,产品现已开源并上传至开源社区http://www.oschina.net/p/aeai-bpm. 产品说 ...
- Mysql主从备份和SQL语句的备份
MySQL服务器的主从配置,本来是一件很简单的事情,无奈不是从零开始,总是在别人已经安装好的mysql服务器之上 ,这就会牵扯到,mysql的版本,启动文件,等一些问题. http://www.cnb ...
- ExtJs4 笔记(4) Ext.XTemplate 模板
ExtJs4 笔记(4) Ext.XTemplate 模板 摘自:http://www.cnblogs.com/lipan/ 本篇将涉及到ExtJs中一个重要的概念,模板.话说Razor很神奇,但是我 ...
- 004_URL 路由 - URL 路由
在Web Form 情况下,每一个 ASPX页面既是一个文件,又是一个队请求自包含的响应.而在 MVC 情况下,请求是由控制器类中的动作方法处理的,而且与硬盘上的文件没有一对一的相互关系. ASP.N ...
- C#的timer类
在C#里关于定时器类就有3个 1.定义在System.Windows.Forms里 2.定义在System.Threading.Timer类里 3.定义在System.Timers.Timer类里 S ...
- SqlServer定时备份数据库和定时杀死数据库死锁解决
上周五组长对我说了一句要杀死数据库的死锁进程,有时候同一时刻不停写入数据库会造成这种情况的发生,因为自己对数据库不是很熟悉,突然组长说了我也就决定一定要倒腾一下,不然自己怎么提高呢?现在不研究,说不定 ...