@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

// Only override drawRect: if you perform custom drawing.

// An empty implementation adversely affects performance during animation.

- (void)drawRect:(CGRect)rect

{

// Drawing code

UIBezierPath *roundedRect = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:[self cornerRadius]];

[roundedRect addClip];

[[UIColor whiteColor] setFill];

UIRectFill(self.bounds);

[[UIColor blackColor] setStroke];

[roundedRect stroke];

if(self.faceUP){

UIImage *faceImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@", [self rankAsString], self.suit]];

if (faceImage) {

CGRect imageRect = CGRectInset(self.bounds,

self.bounds.size.width * (1.0-self.faceCardScaleFactor),

self.bounds.size.height * (1.0-self.faceCardScaleFactor));

[faceImage drawInRect:imageRect];

} else {

[self drawPips];

}

[self drawCorners];

}else{

[[UIImage imageNamed:@"cardback"] drawInRect:self.bounds];

}

NSLog(@"drawRect");

}

这里设置了倒角,阴影,颜色,还有图片

- (void)pushContextAndRotateUpsideDown

{

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSaveGState(context);

CGContextTranslateCTM(context, self.bounds.size.width, self.bounds.size.height);

CGContextRotateCTM(context, M_PI);

}

- (void)popContext

{

CGContextRestoreGState(UIGraphicsGetCurrentContext());

}

#pragma mark - Corners

- (void)drawCorners

{

NSMutableParagraphStyle *paragraphyStyle = [[NSMutableParagraphStyle alloc] init];

paragraphyStyle.alignment = NSTextAlignmentCenter;

UIFont *cornerFont = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];

cornerFont = [cornerFont fontWithSize:cornerFont.pointSize * [self cornerScaleFactor]];

NSAttributedString *cornerText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n%@", [self rankAsString], self.suit] attributes:@{ NSFontAttributeName : cornerFont, NSParagraphStyleAttributeName : paragraphyStyle}];

CGRect textBounds;

textBounds.origin = CGPointMake([self cornerOffset], [self cornerOffset]);

textBounds.size = [cornerText size];

[cornerText drawInRect:textBounds];

[self pushContextAndRotateUpsideDown];

[cornerText drawInRect:textBounds];

[self popContext];

}

这里设置了角落上的suit和rank

@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

iOS绘制view的更多相关文章

  1. iOS圆角view的Swift实现(利用Core Graphics绘制)

    iOS圆角view的Swift实现(利用Core Graphics绘制) 因为app的列表用用到了圆形图片的头像,所以去探究并思考了一下这个问题.首先这个问题有两个方向的解决方案: 把图片弄成圆形的. ...

  2. iOS Programming View and View Hierarchy 视图和视图等级

    iOS Programming  View and View Hierarchy 视图和视图等级 1.1(1)File → New → Project.. From the iOS section, ...

  3. android绘制view的过程

    1 android绘制view的过程简单描述  简单描述可以解释为:计算大小(measure),布局坐标计算(layout),绘制到屏幕(draw):            下面看看每一步的动作到底是 ...

  4. 【转】Android绘制View的过程研究——计算View的大小

    Android绘制View的过程研究——计算View的大小 转自:http://liujianqiao398.blog.163.com/blog/static/18182725720121023218 ...

  5. iOS 设置View阴影

    iOS 设置View投影 需要设置 颜色 阴影半径 等元素 UIView *shadowView = [[UIView alloc] init]; shadowView.frame = CGRectM ...

  6. iOS Programming View Controllers 视图控制器

    iOS Programming View Controllers  视图控制器  1.1  A view controller is an instance of a subclass of UIVi ...

  7. iOS绘制坐标图,折线图-Swift

    坐标图,经常会在各种各样的App中使用,最常用的一种坐标图就是折线图,根据给定的点绘制出对应的坐标图是最基本的需求.由于本人的项目需要使用折线图,第一反应就是搜索已经存在的解决方案,因为这种需求应该很 ...

  8. iOS 绘制1像素的线

    一.Point Vs Pixel iOS中当我们使用Quartz,UIKit,CoreAnimation等框架时,所有的坐标系统采用Point来衡量.系统在实际渲染到设置时会帮助我们处理Point到P ...

  9. Android 绘制view的小知识点

    [onMeasure] 直接继承view或ViewGroup的自定义控件需要重写onMeasure方法并设置wrap_content时的自身大小,否则在布局中使用wrap_content就相当于mat ...

随机推荐

  1. 处理PHP中字符串的常用操作及函数

    1. 确定一个字符串的长度 这是最为常见和基础的例子,对于确定一个字符串的长度,我们应该使用strlen()函数,比如要获取下面字符串$text 的长度: $text = "sunny da ...

  2. SQLServer优化资料整理(二)

    存储过程编写经验和优化措施 一.适合读者对象:数据库开发程序员,数据库的数据量很多,涉及到对SP(存储过程)的优化的项目开发人员,对数据库有浓厚兴趣的人. 二.介绍:在数据库的开发过程中,经常会遇到复 ...

  3. WPF/ArcGIS Engine三维开发和EVC3/4升级到VS项目建议(转)

    系统环境:Windows 7 专业版,Visual Studio 2010,ArcGIS Engine 9.3 1.创建项目 创建一个WPF的项目,必须选择.Net framework 3.5(AE9 ...

  4. 2015第9周三html5学习0

    ​  之前规划了2015关注的技术方向是html5和node.js,虽然前面也搜集过html5相关的评论介绍性能容,但对如何学习和有哪些可利用要经常的看的资源有明显的界定,刚上网搜索了半个多小时,对结 ...

  5. 清除NT Kernel & System占用80端口

    运行'netstat -ano'发现80端口被system占用,进程号'4'转到任务管理器上看pid对应的进程描述是NT kernel & system. 解决方法: 1.1运行'regedi ...

  6. iphone6闪存检测

    iPhone6自从发布以后一直又不少的诟病和非议,比如一机难求,容易掰弯,程序崩溃等, 甚至传出了苹果将要召回这些问题设备,最近有人终于查出了iPhone6安装大量程序后崩溃的原因,原因就是大容量的i ...

  7. hdu1556 Color the ball

    #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> ...

  8. Android.mk文件语法规范及使用模板

    Android.mk文件语法详述 介绍:------------这篇文档是用来描述你的C或C++源文件中Android.mk编译文件的语法的,为了理解她们我们需要您先看完docs/OVERVIEW.h ...

  9. php array相关函数个人小结

    1.array_chunk() 把一个数组分割为新的数组块. 其中每个数组的单元数目由 size 参数决定.最后一个数组的单元数目可能会少几个. 例子   <?php $a=array(&quo ...

  10. indesign 注意事项

    画册 42 * 28.5加出血 42.6 * 29.1用纸 889 * 1194 注意事项:indd文件打印需转曲线 快捷键:ctrl+shift+O ctrl+shift+G (2)应用图片需单独创 ...