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

淘宝联盟优惠券网站建设云服务器安装wordpress程序

淘宝联盟优惠券网站建设,云服务器安装wordpress程序,有什么字体设计网站好,三河建设厅公示网站当我们使用Cocoa的视图的时候#xff0c;我们必须继承NSView或者UIView并且重载函数drawRect:来显示任何内容。但是CALayer实例可以直接使用#xff0c;而无需继承子类。因为CALayer是一个键-值编码兼容的容器类#xff0c;你可以在实例里面存储任意值#xff0c;所以子类实… 当我们使用Cocoa的视图的时候我们必须继承NSView或者UIView并且重载函数drawRect:来显示任何内容。但是CALayer实例可以直接使用而无需继承子类。因为CALayer是一个键-值编码兼容的容器类你可以在实例里面存储任意值所以子类实例化完全可以避免。 1.1 给CALayer提供内容   你可以通过以下任何一种方法指定CALayer实例的内容   (1)使用包含图片内容的CGImageRef来显式的设置图层的contents的属性。   (2)指定一个委托它提供或者重绘内容。   (3)继承CALayer类重载显示的函数。 1.1.1 设置contents属性   图层的图片内容可以通过指定contents属性的值为CGImageRef。当图层被创建的时候或者在任何其他时候这个操作可以在其他实体上面完成如表3所示。    代码 1 设定layer的contents属性   CALayer *theLayer;   // create the layer and set the bounds and position   theLayer[CALayer layer];   theLayer.positionCGPointMake(50.0f,50.0f);   theLayer.boundsCGRectMake(0.0f,0.0f,100.0f,100.0f);   // set the contents property to a CGImageRef   // specified by theImage (loaded elsewhere)   theLayer.contentstheImage;   1.1.2 通过委托提供内容   你可以绘制图层的内容或更好的封装图层的内容图片通过创建一个委托类实现下列方法之一   displayLayer:或drawLayer:inContext:      实现委托重绘的方法并不意味会自动的触发图层使用实现的方法来重绘内容。而是你要显式的告诉一个图层实例来重新缓存内容通过发送以下任何一个方法setNeedsDisplay或者setNeedsDisplayInRect:的消息或者把图层的needsDisplayOnBoundsChange属性值设置为YES。      通过委托实现方法displayLayer:可以根据特定的图层决定显示什么图片还可以更加需要设置图层的contents属性值。下面的例子是“图层的坐标系”部分的它实现displayerLayer:方法根据state的值设置theLayer的contents属性。子类不需要存储state的值因为CALayer的实例是一个键-值编码容器。   代码 2  委托方法displayLayer:的实现示例   - (void)displayLayer:(CALayer *)theLayer   {       // check the value of the layers state key       if ([[theLayer valueForKey:state] boolValue])       {           // display the yes image           theLayer.contents[someHelperObject loadStateYesImage];       }       else {           // display the no image           theLayer.contents[someHelperObject loadStateNoImage];       }   }     如果你必须重绘图层的内容而不是通过加载图片那你需要实现drawLayer:inContext:方法。通过委托可以决定哪些内容是需要的并使用CGContextRef来重绘内容。   下面的例子是“指定图层的几何”部分内容它实现了drawLayer:inContext:方法使用lineWidth键值来重绘一个路径(path),返回therLayer。     代码 3  代理方法drawLayer:inContext:的实现示例   - (void)drawLayer:(CALayer *)theLayer inContext:(CGContextRef)theContext   {     CGMutablePathRef thePath CGPathCreateMutable();     CGPathMoveToPoint(thePath,NULL,15.0f,15.f);     CGPathAddCurveToPoint(thePath,                           NULL,                           15.f,250.0f,                           295.0f,250.0f,                           295.0f,15.0f);     CGContextBeginPath(theContext);     CGContextAddPath(theContext, thePath );     CGContextSetLineWidth(theContext,                           [[theLayer valueForKey:lineWidth] floatValue]);     CGContextStrokePath(theContext);     // release the path     CFRelease(thePath);   }   1.1.3 通过子类提供图层的内容   虽然通常情况不需要这样做但是你仍可以继承CALayer直接重载重绘和显示方法。这个通常发生在你的图层需要定制行为而委托又无法满足需求的时候。   子类可以重载CALayer的显示方法设置图层的内容为适当的图片。下面的例子是“变换图层的几何”部分的内容它提供了和“图层的坐标系”例子相同的功能。不同的是子类定义state为实例的属性而不是根据CALayer的键-值编码容器获取。     代码 4  CALayer display 方法的覆盖示例   - (void)display   {     // check the value of the layers state key     if (self.state)     {         // display the yes image         self.contents[someHelperObject loadStateYesImage];     }     else {         // display the no image         self.contents[someHelperObject loadStateNoImage];     }   }     CALayer子类可以通过重载drawInContext:绘制图层的内容到一个图形上下文。下面的例子是“修改变换的数据结构”的内容它和“指定图层的几何”里面实现委托的办法一样产生相同的图片内容。唯一的不同的是实现委托里面的lineWidth和lineColor现在是子类实例的属性。   Listing 5  覆盖layer的drawInContext:方法示例   - (void)drawInContext:(CGContextRef)theContext   {     CGMutablePathRef thePath CGPathCreateMutable();     CGPathMoveToPoint(thePath,NULL,15.0f,15.f);     CGPathAddCurveToPoint(thePath,                           NULL,                           15.f,250.0f,                           295.0f,250.0f,                           295.0f,15.0f);     CGContextBeginPath(theContext);     CGContextAddPath(theContext, thePath );     CGContextSetLineWidth(theContext,                           self.lineWidth);     CGContextSetStrokeColorWithColor(theContext,                                      self.lineColor);     CGContextStrokePath(theContext);     CFRelease(thePath);   }      继承CALayer并且实现其中的重绘方法并不意味重绘会自动发生。你必须显式的促使实例重新缓存其内容可以通过发送以下任何一个方法setNeedsDisplay或setNeedsDisplayInRect:的消息亦或者设置图层的needsDisplaOnBoundsChange属性为YES。   1.2 修改图层内容的位置   CALayer的属性contentsGravity允许你在图层的边界内容修改图层的contents图片的位置或者伸缩值。默认情况下内容的图像完全填充层的边界忽视自然的图像宽高比。   使用contentsGravity位置常量你可以指定图片位于图层任何一个边界比如位于图层的角落或者图层边界的中心。然而当你使用位置常量的时候contentsCenter属性会被忽略。表1列举了位置常量和他们相应的位置。       layer的contentsGravity属性的定位常量   kCAGravityTopLeft     Positions the content image in the top left corner of the layer.   kCAGravityTop     Positions the content image horizontally centered along the top edge of the layer.   kCAGravityTopRight     Positions the content image in the top right corner of the layer.   kCAGravityLeft     Positions the content image vertically centered on the left edge of the layer.   kCAGravityCenter     Positions the content image at the center of the layer.   kCAGravityRight     Positions the content image vertically centered on the right edge of the layer.   kCAGravityBottomLeft     Positions the content image in the bottom left corner of the layer.   kCAGravityBottom     Positions the content image centered along the bottom edge of the layer.    kCAGravityBottomRight     Positions the content image in the top right corner of the layer.     “图层的坐标系”标识了所支持的内容位置和他们相应的常量。   图 1  layer的contentsGravity属性的定位常量           通过设置contentsGravity属性为其他一个常量(如表2所示)。图层的内容图片可以被向上或者向下拉伸 仅当使用其他任何一个调整大小的常量的时候contentsCenter属性才会对内容图片起作用。     表 2  Layer的 contentsGravity 属性的缩放常量   kCAGravityResize     Resize the content image to completely fill the layer bounds, potentially ignoring the natural aspect of the content. This is the default.   kCAGravityResizeAspect     Resize the content image to scale such that it is displayed as large as possible within the layer bounds, yet still retains its natural aspect.   kCAGravityResizeAspectFill     Resize the content image to scale such that it is displayed filling the layer bounds, yet retaining its natural aspect. This may cause the content to extend outside the layer bounds.   “变换图层的几何”演示了如何使用调整大小的模式来调整一个正方形图像的大小让其适应图层的方形边界。   图 2  Layer的 contentsGravity 属性的缩放常量            注意:使用任何常量kCAGravityResize、kCAGravityResizeAspect和kCAGravityResizeAspectFill和表1中的重心位置常量无关。图层的内容将会填充整个边界所以使用这些常量无法改变图层内容的位置。 转自梦维http://www.dreamingwish.com/dream-2012/coreanimation-programming-guide-e-the-content-layer.html
http://www.zqtcl.cn/news/689810/

相关文章:

  • 免费的成品网站用织梦模板做网站
  • 彩票网站开发 极云有的域名怎样做网站
  • 网店运营推广网站买个天猫店多少钱一个
  • 资讯网站排版广告公司取名大全集
  • 织梦网站seo安徽建设厅网站
  • 北京智能模板建站如何增加网站的索引量
  • 哪个网站专做进口商品的网站备案好麻烦
  • 南京网站制作哪家专业接口网站开发
  • 网站正在建设中9797鲜花网页设计模板
  • wordpress怎么自动更新网站地图现在最流行的网站开发工具
  • 科技局网站查新怎么做vs网站制作教程
  • 网站开发流程文档东莞英文建站公司
  • 怎样建俄文网站wordpress国产主题推荐
  • 网站开发晋升空间 路径秦皇岛房管局官网
  • 中山网站建设sipocms做家电网站好
  • 石家庄建设局网站怎么打不开手机网站素材
  • 电影网站怎么做要多少钱中企动力 网站价格
  • 长沙企业如何建网站爱用建站
  • 在哪个网站上做实验仪器比较好农村住宅设计图集
  • 网站的源代码有什么用wordpress英文博客模板下载
  • 用html5做网站的优点国内家居行业网站开发
  • 临沂企业网站客流统计系统厂家
  • 深圳H5网站开发最新版app下载安装
  • 手机网站免费模板下载成都建设项目环境影响登记网站
  • 上海网站seo公司网站建设公司盈利分析
  • 影评网站怎么做培训总结心得体会
  • 做微站比较好的网站注册子公司流程及所需资料
  • 网站 psd科技公司网站首页
  • 宁波论坛建站模板单页面视频网站
  • 冷饮网站开发背景意义大鱼直播