Custom Control Development set for iOS development series-custom single-choice button or multiple-choice button control development

Source: Internet
Author: User

Custom Control Development set for iOS development series-custom single-choice button or multiple-choice button control development

In our actual development, when we perform login or registration, we often need to select a Protocol. At this time, we need to use the CheckBox button. the CheckBox is a pc or android control that does not exist in ios, so we need to customize it.
The WHC_RadioButton.h header file is as follows:

/// WHC_RadioButton.h // CTBMobileBank // Created by Wu haichao on 15/4/1. // # import
  
   
# Define KWHC_IMAGE_SIZE (15.0) // Icon size @ interface WHC_RadioButton: UIButton @ end
  

The WHC_RadioButton.m source file is as follows:

/// WHC_RadioButton.m // CTBMobileBank // Created by Wu haichao on 15/4/1. /// # import "WHC_RadioButton.h" @ implementation WHC_RadioButton // processing button title area-(CGRect) titleRectForContentRect :( CGRect) contentRect {contentRect. origin. x = KWHC_IMAGE_SIZE; return contentRect;} // processing icon area-(CGRect) imageRectForContentRect :( CGRect) contentRect {CGRect rect = CGRectZero; rect. origin. x = 0.0; rect. origin. y = (CGRectGetHeight (self. bounds)-KWHC_IMAGE_SIZE)/2.0; rect. size. height = KWHC_IMAGE_SIZE; rect. size. width = KWHC_IMAGE_SIZE; return rect;} @ end

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.