@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 API反射实例

    *反射是操纵面向对象范型中元模型的API,其功能十分强大,可帮助我们构建复杂,可扩展的应用.其用途如:自动加载插件,自动生成文档,甚至可用来扩充PHP语言.php反射api由若干类组成,可帮助我们用来 ...

  2. Django1.7官方文档中的tutorial——翻译

    写下你的第一个Django应用,第一部分 让我们通过例子来学习. 通过这篇指南,我们将会带你浏览一遍一个基本投票应用的创建. 它由两部分组成: 1一个让人们查看投票和进行投票的公共站点 2一个让你添加 ...

  3. CodeForces 25E Test KMP

    Description Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tes ...

  4. CSS3匹配屏幕横竖状态

    @media是css3中新定义的,功能非常强大,下面简单讲解一下用css3的@media orientation匹配手机屏幕是横屏还是竖屏. 顾名思义PC是无法匹配横竖屏的,所以orientation ...

  5. jQuery之事件

    (一).事件列表. 1.blur() 当失去焦点时触发.包括鼠标点击离开和TAB键离开. 2.change() 当元素获取焦点后,值改变失去焦点事触发. 3.click() 当鼠标单击时触发. 4.d ...

  6. logstash 处理nginx 错误日志

    2016/08/30 14:52:02 [error] 11325#0: *346 open() "/var/www/zjzc-web-frontEnd/%27%22%2f%3E%3C%2f ...

  7. Min Stack 解答

    Question Design a stack that supports push, pop, top, and retrieving the minimum element in constant ...

  8. ZOJ3477&JAVA大数类

    转:http://blog.csdn.net/sunkun2013/article/details/11822927 import java.util.*; import java.math.BigI ...

  9. 让你的javascript函数拥有记忆功能,降低全局变量的使用

    考虑例如以下场景:假如我们须要在界面上画一个圆,初始的时候界面是空白的.当鼠标移动的时候,圆须要尾随鼠标移动.鼠标的当前位置就是圆心.我们的实现方案是:假设界面上还没有画圆,那么就新创建一个:假设已经 ...

  10. ubuntu14.04下arm-linux-gcc 4.5.1的安装与配置

    使用的是友善之臂mini6410自带光盘中的. 1.对新版本arm-linux-gcc-5.4.1进行解压(注意,下面的C是大写的) tar zxvf arm-linux-gcc-4.5.1-v6-v ...