IOS button Hot Zone zoom in

Source: Internet
Author: User

Apple's iOS human-Computer Interaction Design Guide points out that the button hit hot zone should be no less than 44x44pt, otherwise this button will make the user feel "difficult to use", because obviously clicked up, but there is no response.

But sometimes when we do a custom button, the size of the given button on the design chart is significantly smaller than this number. For example, the thumb on a custom slider I've done before is only 12x12pt, and when I do it I find I don't have a button at all ...

This issue is mentioned in the WWDC Session 216 video as a workaround. It overrides the Pointinside method in the button, so that the button hot zone is not enough 44x44 the size of the first auto-zoom to 44x44, and then determine whether the touch point in the new hot zone.

 

// official in the video sample source -(BOOL) Pointinside: (cgpoint) point withevent: (uievent*)    withevent{44.0 - bounds.size.width;     44.0 - bounds.size.height;     = Cgrectinset (bounds,-0.5 * widthdelta,-0.5 * heightdelta);     return cgrectcontainspoint (bounds, point);}

Apple's iOS human-Computer Interaction Design Guide points out that the button hit hot zone should be no less than 44x44pt, otherwise this button will make the user feel "difficult to use", because obviously clicked up, but there is no response.

But sometimes when we do a custom button, the size of the given button on the design chart is significantly smaller than this number. For example, the thumb on a custom slider I've done before is only 12x12pt, and when I do it I find I don't have a button at all ...

This issue is mentioned in the WWDC Session 216 video as a workaround. It overrides the Pointinside method in the button, so that the button hot zone is not enough 44x44 the size of the first auto-zoom to 44x44, and then determine whether the touch point in//官方在视频中给出的示例源码

 But here are two small questions:

    • When the defined button.frame is greater than 44x44, the hot zone is still reduced to 44x44, causing the button hot zone over 44x44 to lose its response.

    • Bounds variable not defined

The revised code is as follows:

-(BOOL) Pointinside: (cgpoint) point withevent: (uievent*) event{    cgrect bounds = self.bounds;    Wakahara Hot zone is smaller than 44x44, the hot zone is enlarged, otherwise the original size remains unchanged cgfloat Widthdelta = MAX (44.0-bounds.size.width, 0); CGFloat Heightdelta = MAX (44.0-bounds.size.height, 0); bounds = Cgrectinset (bounds, -0.5 * widthdelta, -0.5 * Heightdelta ); return Cgrectcontainspoint (bounds, point);}

IOS button Hot Zone zoom in

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.