IOS Implementation Sideslip Bar effect _ios

Source: Internet
Author: User

Effect

Source: Https://github.com/YouXianMing/iOS-Project-Examples in the Sideviewcontroller

VIEWCONTROLLER.M//Sideviewcontroller////Created by youxianming on 16/6/6. COPYRIGHT©2016 year youxianming.
All rights reserved.

#import "ViewController.h" #import "LeftViewController.h" #import "MainViewController.h" #import "Uiview+setrect.h"

@interface Viewcontroller () {cgfloat _screenwidth;}
@property (nonatomic, strong) Uipangesturerecognizer *pangesture;

@property (nonatomic) Cgpoint panbeginpoint;
@property (nonatomic, strong) Leftviewcontroller *leftviewcontroller;

@property (nonatomic, strong) UIView *leftview;
@property (nonatomic, strong) Mainviewcontroller *mainviewcontroller;

@property (nonatomic, strong) UIView *mainview;
 
 @end @implementation Viewcontroller-(void) viewdidload {[Super viewdidload];
 Init some value.
 
 _screenwidth = Width;
 Add Backgroundview.
 Uiimageview *backgroundview = [[Uiimageview alloc] initWithFrame:self.view.bounds];
 Backgroundview.image = [UIImage imagenamed:@ "Back"]; [Self.view ADDSUBview:backgroundview];
 Leftviewcontroller Self.leftviewcontroller = [[Leftviewcontroller alloc] init];
 Self.leftview = Self.leftViewController.view;
 
 [Self.view AddSubview:self.leftView];
 Mainviewcontroller Self.mainviewcontroller = [[Mainviewcontroller alloc] init];
 Self.mainview = Self.mainViewController.view;
 
 [Self.view AddSubview:self.mainView];
 Pan gesture.
 Self.pangesture = [[Uipangesturerecognizer alloc] initwithtarget:self action: @selector (pangestureevent:)];
[Self.mainview AddGestureRecognizer:self.panGesture]; }-(void) Pangestureevent: (Uipangesturerecognizer *) gesture {cgpoint translation = [gesture translationinview:gesture
 . view];
 
 Cgpoint velocity = [gesture velocityInView:gesture.view];
 CGFloat gap = _screenwidth/3.f * 2;
 
 CGFloat sensitiveposition = _screenwidth/2.f;
  
 if (velocity.x < 0 && _mainview.x <= 0) {//filter off to left side of the case _mainview.x = 0.F; else {if (gesture.state = UigesturerecognizerstatEbegan) {//start _panbeginpoint = translation;
   if (_mainview.x >= sensitiveposition) {_panbeginpoint.x-= gap; } else if (gesture.state = = uigesturerecognizerstatechanged) {//value changes _mainview.x = translation.x-_pan
   
   Beginpoint.x;
   if (_mainview.x <= 0) {//filter off to the left side of the case _mainview.x = 0.F; } else if (gesture.state = uigesturerecognizerstateended) {//end [UIView animatewithduration:0.20f ANI mations:^{_mainview.x >= sensitiveposition?
   (_mainview.x = Gap): (_mainview.x = 0);
  }];
 }}} @end

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.