UIView+QQCorner.m 976 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // UIView+QQCorner.m
  3. // QQCorner
  4. //
  5. // Created by 秦琦 on 2018/10/24.
  6. // Copyright © 2018 QinQi. All rights reserved.
  7. //
  8. #import "UIView+QQCorner.h"
  9. #import "CALayer+QQCorner.h"
  10. #import "QQCornerModel.h"
  11. @implementation UIView (QQCorner)
  12. - (void)updateCornerRadius:(void (^)(QQCorner *))handler {
  13. if (handler) {
  14. handler(self.layer.qq_corner);
  15. }
  16. if (!self.layer.qq_corner.fillColor || CGColorEqualToColor(self.layer.qq_corner.fillColor.CGColor, [UIColor clearColor].CGColor)) {
  17. if (CGColorEqualToColor(self.backgroundColor.CGColor, [UIColor clearColor].CGColor)) {
  18. if (!self.layer.qq_corner.borderColor || CGColorEqualToColor(self.layer.qq_corner.borderColor.CGColor, [UIColor clearColor].CGColor)) {
  19. return;
  20. }
  21. }
  22. self.layer.qq_corner.fillColor = self.backgroundColor;
  23. self.backgroundColor = [UIColor clearColor];
  24. }
  25. [self.layer updateCornerRadius:handler];
  26. }
  27. @end