亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

iOS 純代碼寫個側(cè)滑欄功能

 更新時間:2018年01月15日 09:24:49   作者:鍵盤舞者113  
下面小編就為大家分享一篇iOS 純代碼寫個側(cè)滑欄功能,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

代碼原理就是使用UIView并對其移動來完成,一個twoView作為側(cè)滑欄,一個oneView作為主界面,需要彈出側(cè)滑欄時對twoView向右移動200,當(dāng)隱藏側(cè)滑欄時,向左移動200就行了,twoVIew初始的x地址為-200。

#import <UIKit/UIKit.h> 
 
@interface ViewController : UIViewController<UITableViewDelegate,UITableViewDataSource> 
 
@property (strong, nonatomic) NSArray 
*list; 
 
 
 
@end 
//
// ViewController.m
// First
//
// Created by shanreal-iOS on 17/10/16.
// Copyright © 2017年 shanreal.LongZhenHao. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property(nonatomic,strong)UIView* oneView;
@property(nonatomic,strong)UIView* twoView;
@property(nonatomic,assign)Boolean isShow;
@property(nonatomic,strong)UIButton* btn_back;
@property(nonatomic,strong)UIButton* btn_show;
@end
@implementation ViewController
- (void)viewDidLoad {
 [super viewDidLoad];
 // Do any additional setup after loading the view.
 [self initLeftMenu];
}
-(void)initLeftMenu{
 //self.view.backgroundColor = [UIColor whiteColor];
 _isShow = NO;
 _oneView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width+200, self.view.frame.size.height)];
 _oneView.backgroundColor = [UIColor whiteColor];
 
 _twoView=[[UIView alloc]initWithFrame:CGRectMake(-200, 0, 200, self.view.frame.size.height)];
 _twoView.backgroundColor = [UIColor lightGrayColor];
 
 [self.view addSubview:_oneView];
 [self.view addSubview:_twoView];
 
 _oneView.userInteractionEnabled=YES;
 
 UITapGestureRecognizer *tapGesture1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(backClick)];
 [_oneView addGestureRecognizer:tapGesture1];
 
 _btn_show = [[UIButton alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2-75, self.view.frame.size.height/2-15, 150, 30)];
 _btn_show.backgroundColor = [UIColor whiteColor];
 [_btn_show setTitle:@"彈出側(cè)滑欄" forState:UIControlStateNormal];
 [_btn_show setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
 [_btn_show addTarget:self action:@selector(oneClick) forControlEvents:UIControlEventTouchUpInside];
 [self.oneView addSubview:_btn_show];
 
 _btn_back = [[UIButton alloc]initWithFrame:CGRectMake(20, 100, 150, 30)];
 _btn_back.backgroundColor = [UIColor whiteColor];
 [_btn_back setTitle:@"返回" forState:UIControlStateNormal];
 [_btn_back setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
 [_btn_back addTarget:self action:@selector(twoClick) forControlEvents:UIControlEventTouchUpInside];
 [self.twoView addSubview:_btn_back];
 
 
 
}
-(void)oneClick{
 [UIView animateWithDuration:0.7 animations:^{
  //[_oneView setTransform:CGAffineTransformMakeTranslation(200, 0)];
  [_twoView setTransform:CGAffineTransformMakeTranslation(200, 0)];
 }];
 _isShow = YES;
}
-(void)twoClick{
 [UIView animateWithDuration:0.7 animations:^{
  //[_oneView setTransform:CGAffineTransformMakeTranslation(-200, 0)];
  [_twoView setTransform:CGAffineTransformMakeTranslation(-200, 0)];
 }];
 _isShow = NO;
}
-(void)backClick{
 if(_isShow == YES)
  [self performSelector:@selector(twoClick)];
}
@end

以上這篇iOS 純代碼寫個側(cè)滑欄功能就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • iOS身份證號碼識別示例

    iOS身份證號碼識別示例

    本篇文章主要介紹了iOS身份證號碼識別示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-02-02
  • iOS常見宏理解及使用方法

    iOS常見宏理解及使用方法

    這篇文章主要給大家介紹了關(guān)于iOS常見宏理解及使用方法的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對各位iOS開發(fā)者們具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • iOS開發(fā)實現(xiàn)下載器的基本功能(1)

    iOS開發(fā)實現(xiàn)下載器的基本功能(1)

    這篇文章主要為大家詳細(xì)介紹了iOS開發(fā)實現(xiàn)下載器基本功能的相關(guān)資料,感興趣的小伙伴們可以參考一下
    2016-07-07
  • iOS 11 下適配UITableView 問題

    iOS 11 下適配UITableView 問題

    這篇文章主要介紹了iOS 11 下適配UITableView 問題,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2017-09-09
  • iOS實現(xiàn)比例拼圖的方法示例

    iOS實現(xiàn)比例拼圖的方法示例

    這篇文章主要給大家介紹了關(guān)于iOS實現(xiàn)比例拼圖的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者開發(fā)iOS具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-07-07
  • iOS Xcode創(chuàng)建文件時自動生成的注釋方法

    iOS Xcode創(chuàng)建文件時自動生成的注釋方法

    下面小編就為大家分享一篇iOS Xcode創(chuàng)建文件時自動生成的注釋方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • iOS開發(fā)中Quartz2D控制圓形縮放和實現(xiàn)刷幀效果

    iOS開發(fā)中Quartz2D控制圓形縮放和實現(xiàn)刷幀效果

    這篇文章主要介紹了iOS開發(fā)中Quartz2D控制圓形縮放和實現(xiàn)刷幀效果的方法,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下
    2015-12-12
  • iOS開發(fā)APP跳轉(zhuǎn)到設(shè)置或系統(tǒng)頁面詳解

    iOS開發(fā)APP跳轉(zhuǎn)到設(shè)置或系統(tǒng)頁面詳解

    這篇文章主要為大家介紹了iOS開發(fā)APP跳轉(zhuǎn)到設(shè)置或系統(tǒng)頁面詳解,<BR>有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-06-06
  • runtime獲取屬性和成員變量方法

    runtime獲取屬性和成員變量方法

    這篇文章主要介紹了runtime獲取屬性和成員變量方法,總結(jié)了詳細(xì)用法,對此有興趣的朋友學(xué)習(xí)下。
    2018-02-02
  • 在uiview 的tableView中點擊cell進(jìn)入跳轉(zhuǎn)到另一個界面的實現(xiàn)方法

    在uiview 的tableView中點擊cell進(jìn)入跳轉(zhuǎn)到另一個界面的實現(xiàn)方法

    這篇文章主要介紹了在uiview 的tableView中點擊cell進(jìn)入跳轉(zhuǎn)到另一個界面的實現(xiàn)方法,首先重寫uiviewcontrol方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2016-10-10

最新評論