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