KWTextField.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // KWTextField.m
  3. // westkissMob
  4. //
  5. // Created by iOS on 2022/9/19.
  6. //
  7. #import "KWTextField.h"
  8. @implementation KWTextField
  9. - (instancetype)init {
  10. self = [super init];
  11. if (self) {
  12. [self setStyle];
  13. }
  14. return self;
  15. }
  16. - (void)setStyle {
  17. self.borderStyle = UITextBorderStyleNone;
  18. self.layer.borderColor = [[UIColor colorWithHexString:@"#000000"] CGColor];
  19. self.layer.borderWidth = 1;
  20. self.layer.cornerRadius = 4;
  21. self.layer.masksToBounds = true;
  22. self.backgroundColor = UIColor.whiteColor;
  23. self.font = [UIFont fontWithName:Rob_Regular size:14];
  24. self.textColor = [UIColor colorWithHexString:@"#0b0b0b"];
  25. self.textAlignment = NSTextAlignmentCenter;
  26. }
  27. @end
  28. @implementation UIView(baseInit)
  29. // MARK: - base create
  30. + (UIView *)baseV {
  31. UIView *v = [[UIView alloc] init];
  32. v.backgroundColor = UIColor.whiteColor;
  33. return v;
  34. }
  35. + (UILabel *)baseLb {
  36. UILabel *lb = [[UILabel alloc] init];
  37. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  38. lb.textColor = [UIColor blackColor];
  39. lb.backgroundColor = [UIColor clearColor];
  40. return lb;
  41. }
  42. + (UIImageView *)baseImgV {
  43. UIImageView *imgV = [[UIImageView alloc] init];
  44. imgV.contentMode = UIViewContentModeScaleAspectFit;
  45. return imgV;
  46. }
  47. + (UIStackView *)baseStackV:(BOOL)isVertical {
  48. UIStackView *stackV = [[UIStackView alloc] init];
  49. stackV.axis = isVertical ? UILayoutConstraintAxisVertical : UILayoutConstraintAxisHorizontal;
  50. stackV.spacing = 8;
  51. stackV.alignment = UIStackViewAlignmentFill;
  52. stackV.distribution = UIStackViewDistributionFill;
  53. return stackV;
  54. }
  55. + (UIImage *)snapshotWithView:(UIView *)view {
  56. UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [UIScreen mainScreen].scale);
  57. [view.layer renderInContext:UIGraphicsGetCurrentContext()];
  58. UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  59. UIGraphicsEndImageContext();
  60. return image;
  61. }
  62. @end