Masonry constrained animations and keyboard bounce

Source: Internet
Author: User

要求
When the keyboard is blocking the input box, the input box automatically bounces up to the top of the keyboard.
实现
Here's another way to use the masonry mas_updateConstraints . This method is used to update control constraints.
The specific implementation of the demo can be downloaded to see, this is only posted when the keyboard Popup processing code:

- (void) Keyboardwillchangeframenotification: (Nsnotification *) Notification {Get keyboard Basics (animation duration vs. keyboard height)Nsdictionary *userinfo = [notification UserInfo];CGRect rect = [userinfo[Uikeyboardframebeginuserinfokey] Cgrectvalue]; cgfloat keyboardheight = cgrectgetheight (rect); cgfloat keyboardduration = [userinfo[uikeyboardanimationdurationuserinfokey] doublevalue]; //Modify the bottom margin constraint [_textfield mas_updateconstraints:^ (Masconstraintmaker *make) {make. Bottom. Mas_equalto (- Keyboardheight); }]; //Update constraint [UIView animatewithduration:keyboardduration animations:^{[self. View layoutifneeded];};}

Summarize:
    1. You can add Left/right/top/bottom/size/height/width/insert constraints to the control;
    2. library provides three methods, mas_makeconstraints add constraints, mas_updateconstraints modify constraints, Mas_ Remakeconstraints clears the previous constraint and adds a new constraint;
    3. a constraint on the view can be obtained by view.mas_bottom;
 

Masonry constrained animations and keyboard bounce

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.