KWTextField.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. - (void)sleep:(NSTimeInterval)time {
  30. self.userInteractionEnabled = false;
  31. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, time), dispatch_get_main_queue(), ^{
  32. self.userInteractionEnabled = true;
  33. });
  34. }
  35. - (void)addSubviews:(NSArray <UIView *>*)arr {
  36. for (UIView *temp in arr) {
  37. [self addSubview:temp];
  38. }
  39. }
  40. // MARK: - base create
  41. + (UIView *)baseV {
  42. UIView *v = [[UIView alloc] init];
  43. v.backgroundColor = UIColor.whiteColor;
  44. return v;
  45. }
  46. + (UILabel *)baseLb {
  47. UILabel *lb = [[UILabel alloc] init];
  48. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  49. lb.textColor = [UIColor blackColor];
  50. lb.backgroundColor = [UIColor clearColor];
  51. return lb;
  52. }
  53. + (UIImageView *)baseImgV {
  54. UIImageView *imgV = [[UIImageView alloc] init];
  55. imgV.contentMode = UIViewContentModeScaleAspectFit;
  56. return imgV;
  57. }
  58. + (UIStackView *)baseStackV:(BOOL)isVertical {
  59. UIStackView *stackV = [[UIStackView alloc] init];
  60. stackV.axis = isVertical ? UILayoutConstraintAxisVertical : UILayoutConstraintAxisHorizontal;
  61. stackV.spacing = 8;
  62. stackV.alignment = UIStackViewAlignmentFill;
  63. stackV.distribution = UIStackViewDistributionFill;
  64. return stackV;
  65. }
  66. + (UIImage *)snapshotWithView:(UIView *)view {
  67. UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [UIScreen mainScreen].scale);
  68. [view.layer renderInContext:UIGraphicsGetCurrentContext()];
  69. UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  70. UIGraphicsEndImageContext();
  71. return image;
  72. }
  73. @end