当前位置: 首页 > 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.pierceye.com/news/689810/

相关文章:

  • 公司核名在哪个网站免费申请无限流量卡
  • 做网站和网页的目的和作用是什么山西2地又检出阳性
  • 自助网站建设推广优化策略wordpress中文采集插件
  • 网站开发及运营成本做网站 公司 个体
  • 永久免费建站地址苏州h5网站建设价钱
  • 室内设计网站网站建设中请稍后再访问
  • 十堰网站开发培训编程软件手机
  • 南京网站优化推广微网站缺点
  • 大连零基础网站建设培训哪里有固安县建设局网站
  • 怎么制作网站首页培训心得体会总结简短
  • 商务网站建设 模板长春高端品牌网站建设
  • 做网站比较便宜办公资源网
  • 公司怎么做网页网站遵义网站设计公司
  • 网站建设毕业设计yy直播回放
  • 响应式网站有哪些2017淮南网络推广报价
  • 兰州公司网站建设网站建设筹备方案
  • 租房网站建设做一个跨境电商网站
  • 网站设计制作过程容桂做pc端网站
  • 宜昌市上海中学官网seo文章外包
  • 加强普法网站建设的通知制作婚恋网站
  • 北大荒建设集团有限公司网站网站添加在线qq聊天
  • 网站首页被k咋办上海市企业服务云登录
  • 长安镇网站建设公司大网站制作公司
  • 衡水做网站推广找谁廊坊百度推广排名优化
  • 网站建设毕业报告wordpress微信登录页面
  • 外包网站建设费用包括网站备份crm系统有哪些
  • 高端网站设计推广v信haotg8wordpress 付费后查看
  • cms管理手机网站长春做网站好的公司
  • 可信网站认证 技术支持单位沈阳又一烂尾项目复工
  • 南昌网站建设培训学校做幼儿网站的目标