CALayer+FLEX.m 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // CALayer+FLEX.m
  3. // FLEX
  4. //
  5. // Created by Tanner on 2/28/20.
  6. // Copyright © 2020 FLEX Team. All rights reserved.
  7. //
  8. #import "CALayer+FLEX.h"
  9. @interface CALayer (Private)
  10. @property (nonatomic) BOOL continuousCorners;
  11. @end
  12. @implementation CALayer (FLEX)
  13. static BOOL respondsToContinuousCorners = NO;
  14. + (void)load {
  15. respondsToContinuousCorners = [CALayer
  16. instancesRespondToSelector:@selector(setContinuousCorners:)
  17. ];
  18. }
  19. - (BOOL)flex_continuousCorners {
  20. if (respondsToContinuousCorners) {
  21. return self.continuousCorners;
  22. }
  23. return NO;
  24. }
  25. - (void)setFlex_continuousCorners:(BOOL)enabled {
  26. if (respondsToContinuousCorners) {
  27. if (@available(iOS 13, *)) {
  28. self.cornerCurve = kCACornerCurveContinuous;
  29. } else {
  30. self.continuousCorners = enabled;
  31. // self.masksToBounds = NO;
  32. // self.allowsEdgeAntialiasing = YES;
  33. // self.edgeAntialiasingMask = kCALayerLeftEdge | kCALayerRightEdge | kCALayerTopEdge | kCALayerBottomEdge;
  34. }
  35. }
  36. }
  37. @end