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= UIGraphicsGetCurrentContext();
// Drawing code
}
-(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{
[self drawRect:layer.frame];
//然后拿到 drawRect画的东西,放在图层上。
}
ios中图层和view的关系的更多相关文章
- 转iOS中delegate、protocol的关系
iOS中delegate.protocol的关系 分类: iOS Development2014-02-12 10:47 277人阅读 评论(0) 收藏 举报 delegateiosprocotolc ...
- iOS 中 UIView 和 CALayer 的关系
UIView 有一个名叫 layer ,类型为 CALayer 的对象属性,它们的行为很相似,主要区别在于:CALayer 继承自 NSObject ,不能够响应事件. 这是因为 UIView 除了负 ...
- IOS中两个view的切换
在ios中,rootview为PassWordViewController,secondview为SecondViewController,实现在rootview中听过一个跳转按钮实现跳转到secon ...
- 小记:iOS 中一般对于 view 不依赖 model 的的两种代码书写形式
一. 前言 对于在 MVC 的定义中,view 层是不引用 model 层,view 和 model 是不相往来的 一般开发中,我们都写过 在自定义 view 中增加一个 model 的属性,外接直接 ...
- IOS中封装一个View的思路
一.封装一个View的思路 1.将View内部的业务逻辑(显示内容)封装到View中 2.一般情况下,View的位置应该由父控件来决定,也就是位置不应该固定死在View内部 3.至于View的宽高,根 ...
- iOS中 xib自定义View在storyboard中的使用
1,创建UIView 的SubClass 命名为MyView 2, new一个名为MyView的xib p1 3,配置xib的属性 p2 4,为View 添加背景色,添加一个按钮并定制按钮约束,这里我 ...
- iOS 中如何将View设置为圆角的矩形?
今天刚好需要添加一个圆角的view. 必须先导入头文件. #import <QuartzCore/QuartzCore.h> bgView.layer.cornerRadius = cor ...
- ios中两个view动画切换
@interface ViewController () @property(nonatomic,retain)UIView *redview; @property(nonatomic,retain) ...
- ios中图层的ancorPoint
@interface MJViewController () { CALayer *_layer; } @end @implementation MJViewController - (void)vi ...
随机推荐
- go语言之进阶篇接口的定义和实现以及接口的继承
1.接口的定义和实现以及接口的继承 示例: package main import "fmt" //定义接口类型 type Humaner interface { //方法,只有声 ...
- [leetcode]Anagrams @ Python
原题地址:https://oj.leetcode.com/problems/anagrams/ 题意: Given an array of strings, return all groups of ...
- svn“Previous operation has not finished; run 'cleanup' if it was interrupted“报错的解决方法
今天碰到了个郁闷的问题,svn执行clean up命令时报错“Previous operation has not finished; run 'cleanup' if it was interrup ...
- OAuth2 Demo PHP
OAuth2 Demo PHP 此应用程序的目的是演示OAuth2.0客户端和服务器之间的工作流.如果这是你第一次来这里,试图尝试的现场演示让OAuth2.0流更好的感觉. experimenting ...
- [Git] Change the commit message of my last commit
Did you make a typo in your last commit message? No problem, we can use the git --amend command to c ...
- 【Python】使用torrentParser1.03对多文件torrent的分析结果
Your environment has been set up for using Node.js 8.5.0 (x64) and npm. C:\Users\horn1>cd C:\User ...
- C#.NET常见问题(FAQ)-如何使用2D绘图控件ZedGraph绘制坐标轴和坐标曲线
添加数据:示例添加了一条sin曲线和一条cos曲线,注意cos曲线比sin曲线点更密集(可以用这种方式控制点的采样疏密程度) 默认显示效果如下图所示,可以框选一个部分看放大效果 右击某个点可以 ...
- 从头认识java-15.7 Map(7)-TreeMap与LinkedHashMap
这一章节我们来讨论一下Map两个比較经常使用的实现:TreeMap与LinkedHashMap. 1.TreeMap 特性:依照key来排序 package com.ray.ch14; import ...
- 磁盘I/O的性能评估方法
磁盘I/O的性能评估方法 http://blog.synology.com/blog/?p=2086 通常,我们很容易观察到数据库服务器的内存和CPU压力.但是对I/O压力没有直观的判断方法.磁盘有两 ...
- Spring MVC中forward请求转发2种方式(带参数)
Spring MVC中forward请求转发2种方式(带参数) http://www.51gjie.com/javaweb/956.html