簡單的iOS抽屜效果

2022-09-11 06:33:09 字數 1292 閱讀 9092

#define screenw [uiscreen mainscreen].bounds.size.width

#import "viewcontroller.h"

@inte***ceviewcontroller()

@property(nonatomic,strong)uiview* redview;

@property(nonatomic,strong)uiview*yellowview;

@property(nonatomic,strong)uiview*greenview;

@end

@implementationviewcontroller

- (void)viewdidload

//根據當前最前面檢視的frame確定是否隱藏第二個view

- (void)hiddenelseif(self.greenview.frame.origin.x<0)

}#define rightlocation 275

#define leftlocation -250

#pragma mark pan的方法

- (void)pan:(uipangesturerecognizer*)panelseif(cgrectgetmaxx(self.greenview.frame)//獲取偏移量

cgfloatoffsetx = target-self.greenview.frame.origin.x;

[uiviewanimatewithduration:0.25animations:^];}}

#define maxy  100

//根據偏移量獲取乙個新的frame

#pragma mark - 根據offsetx計算greenview的frame

- (cgrect)changeframewith:(cgfloat)offsetx

//獲取尺寸的縮放比例

cgfloatscale = curh/oldh;

cgfloatcurw = oldw * scale;

cgfloatcury = (self.view.frame.size.height- curh)*0.5;

//更改frame

frame.origin.x= curx;

frame.origin.y= cury;

frame.size.width= curw;

frame.size.height= curh;

returnframe;

}#pragma mark 新增view

- (void)setupview

@end

IOS 簡單抽屜效果

引入每三方類庫 mmdrawercontroller 引入 mmdrawercontroller.h mmdrawervisualstate.h 左右兩個抽屜的controller 和mainviewcontroller mainviewcontroller.h leftviewcontroller...

抽屜效果重寫

這是主介面的內容,可以拖動主介面實現效果 mainviewcontroller.m wangyidrawer created by xiaoyao on 15 2 9.import mainviewcontroller.h import leftviewcontroller.h import rig...

XMG 抽屜效果

1.比如說我建立了3個view void viewdidload 如果想要監聽乙個物件的某個屬性可以使用kvo 只要監聽的屬性一改變,就會呼叫觀察者的這個方法,通知你有新值 void observevalueforkeypath nsstring keypath ofobject id object...