Customizing the Personalization button

Source: Internet
Author: User

Customizing the Personalization button

Effect

Description

By capturing the values of a button's different states to customize our own button animations, I just provide an abstract base class for implementation and a simple example, and the rest requires you to create your own imagination.

Source

Https://github.com/YouXianMing/BaseButton

////BaseControl.h//Basebutton////Created by youxianming on 15/8/27.//Copyright (c) 2015 youxianming. All rights reserved.//#import<UIKit/UIKit.h>@interfaceBasecontrol:uiview/** * ======================== * = override by Subclass = * ======================== * * Trigger Click event*/- (void) TouchEvent;/** * ======================== * = override by Subclass = * ======================== * * Drag to event triggered outside of Rect*/- (void) Touchdragexit;/** * ======================== * = override by Subclass = * ======================== * * Click event start*/- (void) Touchbegin;@end
////BASECONTROL.M//Basebutton////Created by youxianming on 15/8/27.//Copyright (c) 2015 youxianming. All rights reserved.//#import "BaseControl.h"@interfaceBasecontrol () @property (nonatomic, strong) UIButton*button;@end@implementationBasecontrol-(Instancetype) initWithFrame: (CGRect) frame { self=[Super Initwithframe:frame]; if(self) {[self basecontrolsetup]; }        returnSelf ;}- (void) Basecontrolsetup {_button=[[UIButton alloc] initWithFrame:self.bounds];        [Self Addsubview:_button]; //Start clicking[_button addtarget:self Action: @selector (Touchbegin) Forcontrolevents:uicontroleventtouchdown |Uicontroleventtouchdragenter]; //dragging outside of Rect[_button addtarget:self Action: @selector (Touchdragexit) FORCONTROLEVENTS:UICONTROLEVENTTOUCHDR        Agexit]; //Triggering Events[_button addtarget:self Action: @selector (TouchEvent) forcontrolevents:uicontroleventtouchupins IDE];}- (void) touchevent {[nsexception raise:nsinternalinconsistencyexception format:@"Sorry, you cannot directly invoke the method '%@ ' in '%@%d ', you need to overload the method in the subclass by inheriting its subclasses", [NSString stringwithutf8string:__file__].lastpathcomponent, __line__, Nsstringfromselector (_cmd)];}- (void) Touchdragexit {[nsexception raise:nsinternalinconsistencyexception format:@"Sorry, you cannot directly invoke the method '%@ ' in '%@%d ', you need to overload the method in the subclass by inheriting its subclasses", [NSString stringwithutf8string:__file__].lastpathcomponent, __line__, Nsstringfromselector (_cmd)];}- (void) Touchbegin {[nsexception raise:nsinternalinconsistencyexception format:@"Sorry, you cannot directly invoke the method '%@ ' in '%@%d ', you need to overload the method in the subclass by inheriting its subclasses", [NSString stringwithutf8string:__file__].lastpathcomponent, __line__, Nsstringfromselector (_cmd)];}@end

Details

Customizing the Personalization button

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.