CustomShapeButton.m 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // CustomShapeButton.m
  3. // JasonDevelop
  4. //
  5. // Created by Jason Lee on 3/11/14.
  6. // Copyright (c) jasondevelop. All rights reserved.
  7. //
  8. #import "CustomShapeButton.h"
  9. @implementation CustomShapeButton
  10. - (id)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. // Initialization code
  15. }
  16. return self;
  17. }
  18. - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
  19. UIBezierPath *path = nil;
  20. CAShapeLayer *shapeLayer = [[self.layer sublayers] lastObject];
  21. if ([shapeLayer isKindOfClass:[CAShapeLayer class]]) {
  22. path = [UIBezierPath bezierPathWithCGPath:shapeLayer.path];
  23. if (path && [path containsPoint:point]) {
  24. return self;
  25. } else {
  26. return nil;
  27. }
  28. }
  29. return nil;
  30. }
  31. /*
  32. // Only override drawRect: if you perform custom drawing.
  33. // An empty implementation adversely affects performance during animation.
  34. - (void)drawRect:(CGRect)rect
  35. {
  36. // Drawing code
  37. }
  38. */
  39. @end