91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

iOS 純代碼寫個側滑欄功能

發布時間:2020-10-15 20:07:03 來源:腳本之家 閱讀:125 作者:鍵盤舞者113 欄目:移動開發

代碼原理就是使用UIView并對其移動來完成,一個twoView作為側滑欄,一個oneView作為主界面,需要彈出側滑欄時對twoView向右移動200,當隱藏側滑欄時,向左移動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:@"彈出側滑欄" 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 純代碼寫個側滑欄功能就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

贡嘎县| 吉林省| 米泉市| 德昌县| 溆浦县| 怀宁县| 寻甸| 封开县| 泗洪县| 财经| 安仁县| 淮安市| 河北省| 界首市| 崇阳县| 乌兰县| 沁水县| 胶州市| 莒南县| 三门峡市| 奎屯市| 威宁| 囊谦县| 阜新| 大同市| 阳曲县| 伊宁县| 鄯善县| 富平县| 稻城县| 新泰市| 望江县| 南投市| 华池县| 淮北市| 康马县| 梁平县| 兴和县| 年辖:市辖区| 永寿县| 汉川市|