码迷,mamicode.com
首页 > 移动开发 > 详细

IOSButton自定义

时间:2015-08-20 00:59:15      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

+ (APCCustomBackButton *)customBackButtonWithTarget:(id)aTarget action:(SEL)anAction tintColor:(UIColor *)aTintColor

{

    APCCustomBackButton  *button = [APCCustomBackButton buttonWithType:UIButtonTypeCustom];

    CGRect  frame = CGRectMake(0.0, 0.0, kButtonWidth, kButtonHeight);

    button.frame = frame;

    [button addTarget:aTarget action:anAction forControlEvents:UIControlEventTouchUpInside];

    

    CGMutablePathRef  path = CGPathCreateMutable();

    

    CGPoint  p0 = CGPointMake(13.0, 12.0);

    CGPathMoveToPoint(path, NULL, p0.x, p0.y);

    

    CGPoint  p1 = CGPointMake(2.0, 22.0);

    CGPathAddLineToPoint(path, NULL, p1.x, p1.y);

    

    CGPoint  p2 = CGPointMake(13.0, 32.0);

    CGPathAddLineToPoint(path, NULL, p2.x, p2.y);

    

    CALayer  *layer = button.layer;

    CAShapeLayer  *shaper = [[CAShapeLayer alloc] init];

    shaper.frame = CGRectMake(0.0, 0.0, kLayerWidth, kLayerHeight);

    shaper.bounds = CGRectMake(0.0, 0.0, kLayerWidth, kLayerHeight);

    shaper.path = path;

    shaper.lineWidth = kArrowLineWeight;

    shaper.fillColor = [[UIColor clearColor] CGColor];

    shaper.contentsScale = [[UIScreen mainScreen] scale];

    shaper.strokeColor = aTintColor.CGColor;

    [layer addSublayer:shaper];

    

    CGPathRelease(path);

    

    return  button;

}

IOSButton自定义

标签:

原文地址:http://www.cnblogs.com/wcLT/p/4743794.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!