zoukankan      html  css  js  c++  java
  • UILabel里字体带下划线

    - (void)drawRect:(CGRect)rect
     
    {
        
        CGContextRef ctx = UIGraphicsGetCurrentContext();
        
        const CGFloat* colors = CGColorGetComponents(self.textColor.CGColor);
        
        CGContextSetRGBStrokeColor(ctx, colors[0], colors[1], colors[2], 1.0); // RGBA
        
        CGContextSetLineWidth(ctx, 1.0f);
        CGSize tmpSize = [self.text sizeWithFont:self.font constrainedToSize:CGSizeMake(self.frame.size.width, 9999)];
        
        int height = tmpSize.height;
        
        int lineHeight = self.font.pointSize+4;
        
        int maxCount = height/lineHeight;
        
        float totalWidth = [self.text sizeWithFont:self.font constrainedToSize:CGSizeMake(1000, 9999)].width;
        
        for(int i=1;i<=maxCount;i++)
            
        {
            
            float width=0.0;
            if((i*self.frame.size.width-totalWidth)<=0)
                width = self.frame.size.width;
            else
                width = self.frame.size.width - (i* self.frame.size.width - totalWidth);
            CGContextMoveToPoint(ctx, 0, lineHeight*i-1);
            CGContextAddLineToPoint(ctx, width, lineHeight*i-1);
        }
        
        CGContextStrokePath(ctx);
        
        [super drawRect:rect];
    }
  • 相关阅读:
    oracle查看所有角色
    jQuery 异步提交表单实例解析
    oracle查看用户系统权限
    js中日期操作大全
    oracle 查询用户下所有表
    JS语法字典
    JS定时器例子讲解
    开源软件
    rpm的使用
    lvs+keepalived和haproxy+heartbeat区别
  • 原文地址:https://www.cnblogs.com/greywolf/p/2837050.html
Copyright © 2011-2022 走看看