Seemingly often use, their own collection up, convenient to find a backup later.
Effect
Because GIF is being made, the properties are adjusted, so the effect looks bad. If you use the default configuration, the resulting GIF will be very large.
Making GIF:
1. Using Quicktimeplayer, plug your iphone into your Mac, and then make a screen recording, but choose to plug in the iphone and then automatically eject the synced iphone screen on your Mac and click Record.
2. Using Gifbrewery, select the recording file *.mov to create the GIF.
The code is as follows:
#import "XPBaseView.h" @protocol xpdetailtabbarviewdelegate; @interface Xpdetailtabbarview:xpbaseview@property ( Nonatomic,weak) id<xpdetailtabbarviewdelegate> delegate;/** * is bilingual * * @property (nonatomic,assign) BOOL isbilingual;/** * Do you like */@property (nonatomic,assign) BOOL islike; @end @protocol Xpdetailtabbarviewdelegate < Nsobject> @optional-(void) Xpdetailtabbarview: (xpdetailtabbarview*) View Clickindex: (nsinteger) index; @end
#import "XPDetailTabBarView.h" @interface Xpdetailtabbarview () @property (nonatomic,strong) Nsarray *dataimages;@ Property (Nonatomic,strong) UIView *moveview; @property (nonatomic,assign) Nsinteger moveindex; @end @implementation xpdetailtabbarview-(void) initdata{}-(void) initsubviews{self.dataimages = @[@ "Detail_tab_english", @ "Icon_like", @ " Detail_tab_recording ", @" Detail_tab_quiz ", @" Detail_tab_myrecord "]; CGFloat itemwidth = Screen_width/self.dataimages.count; CGFloat itemheight = 44; Self.moveview = [[UIView alloc] Initwithframe:cgrectmake (0, 0, Itemwidth, itemwidth)]; Self.moveView.backgroundColor = Appstylethemeorangecolor; [Self addSubview:self.moveView]; for (int i = 0; i<self.dataimages.count; i++) {UIButton *button = [UIButton buttonwithtype:uibuttontypecusto M]; Button.tag = 20000+i; Button.frame = CGRectMake (i*itemwidth, 0, Itemwidth, itemheight); Button.backgroundcolor = [Uicolor Clearcolor]; [ButtonSetimage:[uiimage imagenamed:[self.dataimages Objectatindex:i]] forstate:uicontrolstatenormal]; [Button addtarget:self action: @selector (buttonclicked:) forcontrolevents:uicontroleventtouchupinside]; [Self Addsubview:button]; }}-(void) Setmoveindex: (nsinteger) moveindex{Nsinteger animationtype = 1;//1 Left, 2 right if (Moveindex > _moveindex) { Animationtype = 2; } _moveindex = Moveindex; CGFloat itemwidth = Screen_width/self.dataimages.count; CGFloat itemheight = 44; CGRect rect = CGRectMake (moveindex*itemwidth, 0, Itemwidth, itemheight); WS (weakself) [UIView animatewithduration:0.2 animations:^{if (animationtype = = 2) {//Right Weakself.movev Iew.frame = CGRectMake (rect.origin.x+2, RECT.ORIGIN.Y, Rect.size.width, rect.size.height); } else if (Animationtype = = 1) {//Left weakSelf.moveView.frame = CGRectMake (rect.origin.x-2, RECT.ORIGIN.Y, rect.si Ze.width, Rect.size.height); }} completion:^ (BOOL finished) {[UIView animatewithduration:0.3 animations:^{if (animationtype = = 2) {//Right WeakSelf.moveView.frame = CGRectMake (rect.origin.x-5, RECT.ORIGIN.Y, Rect.size.width, rect.size.height); } else if (Animationtype = = 1) {//Left weakSelf.moveView.frame = CGRectMake (rect.origin.x+5, RECT.ORIGIN.Y, rec T.size.width, Rect.size.height); }} completion:^ (BOOL finished) {[UIView animatewithduration:0.4 animations:^{weakself. Moveview.frame = rect; } completion:^ (BOOL finished) {}]; }]; }];} -(void) Setisbilingual: (BOOL) isbilingual{_isbilingual = isbilingual; UIButton *button = [self viewwithtag:20000]; if (isbilingual) {[Button setimage:[uiimage imagenamed:@ "Detail_tab_english"] forstate:uicontrolstatenormal]; }else{[button setimage:[uiimage imagenamed:@ "Detail_tab_bilingual"] forstate:uicontrolstatenormal];}}-(void) Setislike: (BOOL) islike{_islike = islike; UIButton *button = [self viewwithtag:20001]; if (islike) {[Button setimage:[uiimage imagenamed:@ "icon_like_selected"] forstate:uicontrolstatenormal]; }else{[button setimage:[uiimage imagenamed:@ "Icon_like"] forstate:uicontrolstatenormal]; }}-(void) buttonclicked: (uibutton*) button{Nsinteger index = button.tag-20000; Self.moveindex = index; if (self.delegate && [self.delegate respondstoselector: @selector (xpdetailtabbarview:clickindex:)]) {[SELF.D Elegate xpdetailtabbarview:self Clickindex:index]; }} @end
IOS Custom Swipe Toggle Tabbar