Fat says things-----iOS Development Tips Cancel keyboard response and screenshot function

Source: Internet
Author: User

1.UILable content Blur

On the screen of a non-retina ipad Mini, the origin value of a uilable frame, if it has a decimal place (such as 0.5), causes the display to blur, so it is best to use the origin of the integer value.

2. Cancel the keyboard response

Resignfirstresponder is usually used to cancel keyboard response events, but there are three ways to cancel the keyboard response.

First: Overload the Touchesbegin method in the Uiviewcontroller, and then execute [self.view Endediting:yes] in the inside, then click anywhere in the Uiviewcontroller to cancel the keyboard response.

Second type: direct execution [[uiapplication sharedapplication] sendaction: @selector:(resignfirstresponder) To:nil From:nil Forevent:nil ]; Used when getting the current uiviewcontroller is more difficult.

The third type: direct execution [[[UIApplication sharedapplication] Keywindow] endediting:yes];

3. Screen cutting function

the screenshot function of IOS can save the UI elements of the current page to UIImage, which can be used in the system-provided API for applications above IOS7:-(UIView *) Snapshotviewafterscreenupdates: (BOOL) afterupdates to achieve the screenshot function, for applications below IOS7 can be implemented by the following code to achieve the screenshot function:

iOS7 screenshot Method-(UIImage *) Captureimagefromview: (UIView *) view{    CGRect screenrect = [view bounds];    Uigraphicsbeginimagecontext (screenrect.size);    Cgcontextref CTX = Uigraphicsgetcurrentcontext ();    [View.layer Renderincontext:ctx];    UIImage *image = Uigraphicsgetimagefromcurrentimagecontext ();    Uigraphicsendimagecontext ();    return image;

Fat says things-----iOS Development Tips Cancel keyboard response and screenshot function

Related Article

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.