获取extension,判断第一次

This commit is contained in:
2025-10-27 21:11:28 +08:00
parent a9625369f7
commit d4ebfb9909
6 changed files with 92 additions and 42 deletions

View File

@@ -8,22 +8,29 @@
#import "ViewController.h"
@interface ViewController ()
@property (nonatomic,strong)UITextField *textField;
@property (nonatomic, strong) UITextView *textView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor grayColor];
self.textField = [[UITextField alloc] init];
self.textField.frame = CGRectMake(100, 100, 200, 40);
self.textField.layer.borderWidth = 1;
self.textField.layer.borderColor = [UIColor redColor].CGColor;
[self.view addSubview:self.textField];
[self setupTextField];
}
- (void)setupTextField {
CGRect frame = CGRectMake(([UIScreen mainScreen].bounds.size.width - 200)/2, ([UIScreen mainScreen].bounds.size.height - 200)/2, 200, 200);
self.textView = [[UITextView alloc] initWithFrame:frame];
self.textView.text = @"测试";
self.textView.layer.borderColor = [UIColor blackColor].CGColor;
self.textView.layer.borderWidth = 0.5;
[self.view addSubview:self.textView];
[self.textView becomeFirstResponder];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.textView resignFirstResponder];
}