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];
    }
  • 相关阅读:
    LPC1788做U盘的时候对命令的响应
    一种比较简单的在USB U盘中访问nandflash的方法
    LPC1788的LCD接口驱动真彩屏
    lPC1788的GPIO驱动
    LPC1788定时器使用
    LPC1788系统时钟初始化
    LPC1788的IIC使用
    lPC1788驱动SDRAM
    LPC1788的内部EEPROM使用
    LPC1788的spi使用
  • 原文地址:https://www.cnblogs.com/greywolf/p/2837050.html
Copyright © 2011-2022 走看看