Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2604127
  • 博文数量: 877
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 5920
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-05 12:25
个人简介

技术的乐趣在于分享,欢迎多多交流,多多沟通。

文章分类

全部博文(877)

文章存档

2021年(2)

2016年(20)

2015年(471)

2014年(358)

2013年(26)

分类: iOS平台

2015-11-20 14:57:21

        CGContextRef context = UIGraphicsGetCurrentContext();

    

//        CGContextAddRect(context, CGRectMake(200, 246, 121, 30));

        //// Text Drawing

        CGRect textRect = CGRectMake(waterX, waterY, waterW, waterH);

        {

            NSString* textContent = @"Hello, World!";

            NSMutableParagraphStyle* textStyle = NSMutableParagraphStyle.defaultParagraphStyle.mutableCopy;

            textStyle.alignment = NSTextAlignmentLeft;

    

            NSDictionary* textFontAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize: UIFont.labelFontSize], NSForegroundColorAttributeName: UIColor.blackColor, NSParagraphStyleAttributeName: textStyle};

    

            CGFloat textTextHeight = [textContent boundingRectWithSize: CGSizeMake(textRect.size.width, INFINITYoptions: NSStringDrawingUsesDeviceMetrics attributes: textFontAttributes context: nil].size.height;

            CGContextSaveGState(context);

    

    //        CGContextAddRect(context, CGRectMake(200, 246, 121, 30));

    

    //        CGContextClipToRect(context, textRect);

            [textContent drawInRect: CGRectMake(CGRectGetMinX(textRect), CGRectGetMinY(textRect) + (CGRectGetHeight(textRect) - textTextHeight) / 2, CGRectGetWidth(textRect), textTextHeight) withAttributes: textFontAttributes];

            

//             CGContextShowTextAtPoint (context, 40, 0, "Quartz 2D", 9);

            

            

//            // 画文字

//            NSString *str = @"的额搜风搜分手了粉色发俄双方说法offFF瓦房你F回复F入会费WFH;飞;FN返回WFH;哦发货;F回复;FHISFHSIFH我皮肤好APIFRHi分红AWFHIOF威锋网i";

//            [str drawInRect:CGRectMake(50, 50, 100, 100) withAttributes:nil];

            

            CGContextRestoreGState(context);

        }

阅读(930) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~