2/28
杂
[self.messageField resignFirstResponder]
[self.messageField endEditing:YES]
[self.view endEditing:YES];
[self.messageField becomeFirstResponder]
UIKeyboardWillChangeFrameNotification
设置按钮内子控件的设置:
self.title.text = @"XXX";
- (void)setTitle:(NSString *)title forState:(UIControlState)state;
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;
- (void)setImage:(UIImage *)image forState:(UIControlState)state;
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state;
设置自定义按钮内子控件的frame
- (void)layoutSubviews{
[super layoutSubviews];
}
通知叫出键盘
- (void)viewDidLoad {
[super viewDidLoad];
UIView *leftView = [[UIView alloc] init];
leftView.frame = CGRectMake(0, 0, 10, 0);
self.messageField.leftView = leftView;
self.messageField.leftViewMode = UITextFieldViewModeAlways;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
}
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - 键盘处理
- (void)keyboardWillChangeFrame:(NSNotification *)note {
CGRect rect = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
double duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^{
CGFloat ty = [UIScreen mainScreen].bounds.size.height - rect.origin.y;
self.view.transform = CGAffineTransformMakeTranslation(0, - ty);
}];
}
[UIView animateWithDuration:2.0 animations:^{
self.tempView.transform = CGAffineTransformMakeScale(0.5, 0.5);
self.tempView.transform = CGAffineTransformMakeTranslation(-100, 100);
self.tempView.transform = CGAffineTransformMakeRotation(-M_PI_4);
CGAffineTransform translation = CGAffineTransformMakeTranslation(-100, 100);
CGAffineTransform scaleTranslation = CGAffineTransformScale(translation, 0.5, 0.5);
CGAffineTransform rotateScaleTranslation = CGAffineTransformRotate(scaleTranslation, M_PI_2);
self.tempView.transform = rotateScaleTranslation;
}];
// 累加,传一个transform,再累加一个新的transfrom
[UIView animateWithDuration:1.0 animations:^{
self.tempView.transform = CGAffineTransformScale(self.tempView.transform, 0.8, 0.8)
self.tempView.transform = CGAffineTransformRotate(self.tempView.transform, M_PI_4)
}]
[UIView animateWithDuration:2.0 animations:^{
self.tempView.transform = CGAffineTransformIdentity;
}];
图片拉伸(不用代码实现)