IOSButton自定义
2015-08-19 23:10
190 查看
+ (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;
}
{
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;
}
相关文章推荐
- IOS类和对象的概念
- TI-RTOS Sys-Bios操作系统:task栈溢出检测方法
- iOS之缓存数据
- IOS设置圆形按钮的简单实现
- TI-RTOS Sys-Bios操作系统:Hwi创建方法
- iOS runtime 机制浅析
- iOS开发页面之间的几种传值方式
- iOS Parse教程——如何使用Parse在iOS应用创建后台服务
- 开启/关闭 iOS 原生 左滑动 pop 视图功能
- [IOS]CoreAnimation基础[翻译2部分]
- iOS中的BASE64编码和MD5编码使用
- iOS项目开发实战——制作视图的平移动画以及解决移动异常问题
- iOS项目的目录结构
- [IOS]CoreAnimation基础[翻译1部分]
- iOS动画——CoreAnimation
- UVA 11111-Generalized Matrioshkas(栈)
- iOS学习笔记6-关于NSNotificationCenter及同步异步
- ios 导航控制器
- IOS-笔记9(多MVC,View间转换)
- ios文件管理