ios中图层和view的关系】的更多相关文章

-(void)viewMethod{ //1: 要明白uiview内部是这样实现 CALayer *layer1= [CALayer layer]; layer.delegate=self; [layer1 setNeedsDisplay]; [self.layer addSublayer:layer]; } - (void)drawRect:(CGRect)rect { //contex和ctx是相同的,所以在view画的东西都在上下文中. CGContextRef context= UIGr…
iOS中delegate.protocol的关系 分类: iOS Development2014-02-12 10:47 277人阅读 评论(0) 收藏 举报 delegateiosprocotolcategoryobject-c 刚开始接触iOS,对delegate.protocol这两个概念比较模糊.参考了一些资料,记录下来体会. 1.protocol           protocol和interface的概念类似,是object-c语法的一部分.protocol就是一系列不属于任何类的…
UIView 有一个名叫 layer ,类型为 CALayer 的对象属性,它们的行为很相似,主要区别在于:CALayer 继承自 NSObject ,不能够响应事件. 这是因为 UIView 除了负责响应事件 ( 继承自 UIReponder ) 外,它还是一个对 CALayer 的底层封装.可以说,它们的相似行为都依赖于 CALayer 的实现,UIView 只不过是封装了它的高级接口而已. 那 CALayer 是什么呢? CALayer(图层) 文档对它定义是:管理基于图像内容的对象,允许…
在ios中,rootview为PassWordViewController,secondview为SecondViewController,实现在rootview中听过一个跳转按钮实现跳转到secondview中,实现方法如下: 在PassWordViewController.h中添加button的事件 -(IBAction) landButtonPressed:(id) sender; 在PassWordViewController.m中 button的实现事件如下: -(IBAction)…
一. 前言 对于在 MVC 的定义中,view 层是不引用 model 层,view 和 model 是不相往来的 一般开发中,我们都写过 在自定义 view 中增加一个 model 的属性,外接直接传个 model 来,在 view 中 model 的 set 方法里对 view 的控件赋值的代码,例如在自定义 UITableViewCell 时用的很多,此时 view 是直接引用了 model 基于封装的思想,我们需要竟可能的复用我们的代码,复用我们的 view,这时我们需要进行解耦,不依赖…
一.封装一个View的思路 1.将View内部的业务逻辑(显示内容)封装到View中 2.一般情况下,View的位置应该由父控件来决定,也就是位置不应该固定死在View内部 3.至于View的宽高,根据具体情况来决定要不要由父控件决定…
1,创建UIView 的SubClass 命名为MyView 2, new一个名为MyView的xib p1 3,配置xib的属性 p2 4,为View 添加背景色,添加一个按钮并定制按钮约束,这里我添加的约束为垂直居中,Button与View等宽,Button左边起点位置为0. p3 5,设置xib中的File’s owner = MyView, 拖拽view 到关联的代码中命名为contentView p4 6, 在storyboard 中对ViewController 添加一个View,之…
今天刚好需要添加一个圆角的view. 必须先导入头文件. #import <QuartzCore/QuartzCore.h> bgView.layer.cornerRadius = cornerRadiusInPixels;//设置角度大小 bgView.layer.masksToBounds = YES; bgView.opaque = NO;…
@interface ViewController () @property(nonatomic,retain)UIView *redview; @property(nonatomic,retain)UIView *yellowview; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.redview=[[UIView alloc] initWithFrame:CGRectMa…
@interface MJViewController () { CALayer *_layer; } @end @implementation MJViewController - (void)viewDidLoad { [super viewDidLoad]; CALayer *layer = [CALayer layer]; layer.bounds = CGRectMake(, , , ); layer.position = CGPointMake(, ); layer.backgrou…