解决做Mansonry/Autolayout动画时,uitextfield中的文字会向上抖动或跳动的问题
2016-03-17 09:42
886 查看
今天用了Masonry做了一个动画,动画的时候发生了一个奇怪的现象
居然画面中所有的UITextfield在切换焦点的里面文字都向上抖动一下或者说是跳动一下。醉醉的 ,后来改了一行代码就好了初始代码如下
最后发现只要将最后一句[self layoutIfNeeded];改为[self layoutSubviews];就好了
居然画面中所有的UITextfield在切换焦点的里面文字都向上抖动一下或者说是跳动一下。醉醉的 ,后来改了一行代码就好了初始代码如下
+(BOOL)requiresConstraintBasedLayout{ return YES; } -(void)updateConstraints{ [self.imgCompanyIcon mas_updateConstraints:^(MASConstraintMaker *make) { make.centerX .equalTo(self.mas_centerX); make.width.equalTo(@90); make.height.equalTo(@90); make.top.equalTo(self.mas_top).with.offset(86 -180*self.isKeybordShow); }]; [super updateConstraints]; } #pragma mark - Keyboard Notification -(void)keyboardWillShow:(NSNotification *)notifi{ NSDictionary* userInfo = [notifi userInfo]; NSValue* animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey]; NSTimeInterval animationDuration; [animationDurationValue getValue:&animationDuration]; self.isKeybordShow = YES; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; [UIView animateWithDuration:animationDuration animations:^{ [self layoutIfNeeded]; }]; }
最后发现只要将最后一句[self layoutIfNeeded];改为[self layoutSubviews];就好了
相关文章推荐
- QML中的SequentialAnimation队列动画
- UIPageViewController - 页面视图控制器
- NSValue的使用
- android stuido 快捷键
- iOS中UIScrollerView的用法及基于AotoLayout的控件悬停
- 警告框和操作表的使用方法
- 关于setNeedsDisplay、setNeedsLayout方法,UIView的layoutSubviews和drawRect方法何时调用
- UI基础控件的使用1
- 使用AsyncDisplayKit提升UICollectionView和UITableView的滚动性能
- Symfony2中被遗弃的getRequest()方法分析
- required file `./ltmain.sh' not found
- iOS 蓝牙开发BLE4.0的资料收集,基于原生Core Bluetooth
- github上 fork + Pull Request 开发模式
- android.support.design.widget.CoordinatorLayout中 android:fitsSystemWindows="true"属性的作用
- Java 中如何对 Iterator<Text> values 实现两次遍历
- UI控件--UIScrollView
- IOS学习 UIDatePicker 省市区 三联动
- Symfony2中被遗弃的getRequest()方法分析
- UI组件——TextView
- mysql Column 'dbvalue' in where clause is ambiguous解决方案