继承UITextField,重写drawRect方法
- (void)drawRect:(CGRect)rect {
[superdrawRect:rect];
UIToolbar *bar = [[UIToolbaralloc] initWithFrame:CGRectMake(0,0, SCREEN_WIDTH,44)];
UIButton *button = [[UIButtonalloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 60, 7,50, 30)];
[button setTitle:@'完成'forState:UIControlStateNormal];
[button setTitleColor:[UIColorredColor] forState:UIControlStateNormal];
button.layer.borderColor = [UIColorredColor].CGColor;
button.layer.borderWidth =1;
button.layer.cornerRadius =3;
[bar addSubview:button];
self.inputAccessoryView = bar;
[button addTarget:selfaction:@selector(print)forControlEvents:UIControlEventTouchUpInside];
}
``
网友评论