欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS實(shí)現(xiàn)側(cè)滑欄效果

 更新時(shí)間:2016年08月10日 11:28:24   作者:YouXianMing  
這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)側(cè)滑欄效果,點(diǎn)擊側(cè)邊拉出相應(yīng)菜單,感興趣的小伙伴們可以參考一下

效果

 

源碼:https://github.com/YouXianMing/iOS-Project-Examples 中的 SideViewController 

//
// ViewController.m
// SideViewController
//
// Created by YouXianMing on 16/6/6.
// Copyright © 2016年 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) {
  
  // 過濾掉向左側(cè)滑過頭的情形
  _mainView.x = 0.f;
  
 } else {
  
  if (gesture.state == UIGestureRecognizerStateBegan) {
   
   // 開始
   _panBeginPoint = translation;
   
   if (_mainView.x >= sensitivePosition) {
    
    _panBeginPoint.x -= gap;
   }
   
  } else if (gesture.state == UIGestureRecognizerStateChanged) {
   
   // 值變化
   _mainView.x = translation.x - _panBeginPoint.x;
   
   if (_mainView.x <= 0) {
    
    // 過濾掉向左側(cè)滑過頭的情形
    _mainView.x = 0.f;
   }
   
  } else if (gesture.state == UIGestureRecognizerStateEnded) {
   
   // 結(jié)束
   [UIView animateWithDuration:0.20f animations:^{
    
    _mainView.x >= sensitivePosition ? (_mainView.x = gap) : (_mainView.x = 0);
   }];
  }
 }
}

@end

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • iOS視頻壓縮存儲(chǔ)至本地并上傳至服務(wù)器實(shí)例代碼

    iOS視頻壓縮存儲(chǔ)至本地并上傳至服務(wù)器實(shí)例代碼

    本篇文章主要介紹了iOS視頻壓縮存儲(chǔ)至本地并上傳至服務(wù)器實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • iOS實(shí)現(xiàn)微信朋友圈與搖一搖功能

    iOS實(shí)現(xiàn)微信朋友圈與搖一搖功能

    這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)微信朋友圈與搖一搖功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-08-08
  • iOS利用CoreImage實(shí)現(xiàn)人臉識別詳解

    iOS利用CoreImage實(shí)現(xiàn)人臉識別詳解

    OS的人臉識別從iOS 5(2011)就有了,不過一直沒怎么被關(guān)注過。人臉識別API允許開發(fā)者不僅可以檢測人臉,也可以檢測到面部的一些特殊屬性,比如說微笑或眨眼。下面這篇文章主要給大家介紹了iOS利用CoreImage實(shí)現(xiàn)人臉識別的相關(guān)資料,需要的朋友可以參考下。
    2017-05-05
  • iOS中添加文本鏈接和圖片示例代碼

    iOS中添加文本鏈接和圖片示例代碼

    這篇文章主要給大家介紹了關(guān)于iOS中添加文本鏈接和圖片的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面跟著小編一起來學(xué)習(xí)學(xué)習(xí)吧。
    2017-07-07
  • IOS開發(fā)代碼分享之獲取啟動(dòng)畫面圖片的string

    IOS開發(fā)代碼分享之獲取啟動(dòng)畫面圖片的string

    本文是IOS開發(fā)代碼分享系列的第一篇文章,這里分享下獲取啟動(dòng)畫面圖片的string的代碼,本代碼支持 iPhone 6 以下. 支持 iPhone 及 iPad,非常實(shí)用,希望對大家有所幫助
    2014-09-09
  • iOS獲取cell中webview的內(nèi)容尺寸

    iOS獲取cell中webview的內(nèi)容尺寸

    這篇文章主要介紹了iOS獲取cell中webview內(nèi)容尺寸,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • 使用ARM匯編破解iOS程序基礎(chǔ)知識分享

    使用ARM匯編破解iOS程序基礎(chǔ)知識分享

    最近對iOS逆向工程很感興趣。但查到的資料中都涉及到有ARM匯編,但都只是很泛地用到,并沒有對iOS上的ARM匯編進(jìn)行比較詳細(xì)的講解。因此,經(jīng)過一系列的學(xué)習(xí)對iOS下的ARM有了一定的理解。在此打算用幾篇文字記錄下來, 限于本人水平有限,如有錯(cuò)誤請不吝賜教。
    2015-11-11
  • iOS微信第三方登錄實(shí)例

    iOS微信第三方登錄實(shí)例

    這篇文章主要為大家詳細(xì)介紹了iOS微信第三方登錄實(shí)現(xiàn)過程,一步一步告訴大家iOS微信實(shí)現(xiàn)第三方登錄的方法,感興趣的小伙伴們可以參考一下
    2016-12-12
  • Objective-C處理空字符串和頁面?zhèn)髦导白远x拷貝

    Objective-C處理空字符串和頁面?zhèn)髦导白远x拷貝

    這篇文章主要介紹了Objective-C處理空字符串和頁面?zhèn)髦导白远x拷貝的相關(guān)方法,在iOS應(yīng)用項(xiàng)目開發(fā)中經(jīng)常會(huì)用到,需要的朋友可以參考下
    2016-01-01
  • iOS開發(fā)image背景圖片拉伸問題解決分析

    iOS開發(fā)image背景圖片拉伸問題解決分析

    這篇文章主要為大家介紹了iOS開發(fā)image背景圖片拉伸問題解決分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07

最新評論