zoukankan      html  css  js  c++  java
  • 下划线按钮

    #import <UIKit/UIKit.h>

    @interface CXUnderLineButton : UIButton

    + (CXUnderLineButton *) underlinedButton;

    @end

    #import "CXUnderLineButton.h"

    @implementation CXUnderLineButton

    - (id)initWithFrame:(CGRect)frame

    {

        self = [super initWithFrame:frame];

        if (self) {

            // Initialization code

        }

        return self;

    }

    + (CXUnderLineButton*) underlinedButton {

        CXUnderLineButton* button = [[CXUnderLineButton alloc] init];

        return button;

    }

    - (void) drawRect:(CGRect)rect {

        CGRect textRect = self.titleLabel.frame;

        

        // need to put the line at top of descenders (negative value)

        CGFloat descender = self.titleLabel.font.descender;

        

        CGContextRef contextRef = UIGraphicsGetCurrentContext();

        

        // set to same colour as text

        CGFloat offset = 1.f;

        CGContextSetStrokeColorWithColor(contextRef, self.highlighted?[UIColor grayColor].CGColor: self.titleLabel.textColor.CGColor);

        

        CGContextMoveToPoint(contextRef, textRect.origin.x, textRect.origin.y + textRect.size.height + descender + offset);

        

        CGContextAddLineToPoint(contextRef, textRect.origin.x + textRect.size.width, textRect.origin.y + textRect.size.height + descender + offset);

        

        CGContextClosePath(contextRef);

        

        CGContextDrawPath(contextRef, kCGPathStroke); 

    /*

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

    // An empty implementation adversely affects performance during animation.

    - (void)drawRect:(CGRect)rect

    {

        // Drawing code

    }

    */

    @end

  • 相关阅读:
    ORA16014 与 ORA00312
    ORA26687
    ORA32004问题解决
    ORA23616:执行块5失败
    Streams实践之Schemas级复制
    Streams FAQ
    ORA23622: 正在执行操作SYS.DBMS_STREAMS_ADM.MAINTAIN_GLOBAL
    为什么白帽SEO更好?
    HyperV虚拟机安装及网卡无法找到,驱动无法安装解决办法
    Memcahed分布式缓存服务替换Session解决方案——简单介绍[转]
  • 原文地址:https://www.cnblogs.com/ldc529/p/3874887.html
Copyright © 2011-2022 走看看