我的iOS學習歷程 手勢

2021-07-07 08:32:02 字數 1982 閱讀 7502

新增手勢步驟

初始化手勢 新增手勢觸發呼叫的方法

把手勢新增到檢視上

釋放手勢

1.長按

uilongpressgesturerecognizer *longpress = [[uilongpressgesturerecognizer alloc] initwithtarget:

self

action:

@selector(longpressaction:)];

// 設定長按時間

longpress.minimumpressduration = 2.0;

[imageview addgesturerecognizer:longpress];

[longpress release];

2.旋轉

uirotationgesturerecognizer *rotation = [[uirotationgesturerecognizer alloc] initwithtarget:

self

action:

@selector(rotationaciton:)];

[imageview addgesturerecognizer:rotation];

[rotation release];

3.捏合

uipinchgesturerecognizer *pinch = [[uipinchgesturerecognizer alloc] initwithtarget:

self

action:

@selector(pinchaciton:)];

[imageview addgesturerecognizer:pinch];

[pinch release];

4.平移

uipangesturerecognizer *pan = [[uipangesturerecognizer alloc] initwithtarget:

self

action:

@selector(panaction:)];

[imageview addgesturerecognizer:pan];

[pan release];

5.輕掃

uiswipegesturerecognizer *swipe = [[uiswipegesturerecognizer alloc] initwithtarget:

self

action:

@selector(swipeaction:)];

swipe.direction = uiswipegesturerecognizerdirectionleft;

[imageview addgesturerecognizer:swipe];

[swipe release];

6.邊緣掃

uiscreenedgepangesturerecognizer *screenedgepan = [[uiscreenedgepangesturerecognizer alloc] initwithtarget:

self

action:

@selector(screenedgepanaction:)];

// 設定下從哪個邊緣開始掃

screenedgepan.edges = uirectedgeright;

[imageview addgesturerecognizer:screenedgepan];

[screenedgepan release];

每個手勢新增的方法可以在下面自己寫例如

實現輕拍方法:

- (void)tapaction:(uitapgesturerecognizer *)tap

這就是我們的手勢學習了

我的iOS 學習 學習基本手勢

ios設計手勢符合人的操作習慣,提供了良好的使用者體驗。uigesturerecognizer 手勢抽象類,實現類 uitapgesturerecognizer 輕擊 uilongpressgesturerecognizer 長按 uiswipegesturerecognizer 輕掃 uipang...

我的iOS學習歷程 MVC模式

我們先建立乙個rootviewcontroller類 每乙個檢視控制器 都自帶乙個 view,並且這個view跟螢幕一樣大小 implementation rootviewcontroller 這個方法是載入檢視的 並且載入的是自己自帶的view void loadview instancetype...

我的python學習歷程

這是接著剛剛的部落格 用if語句處理列表 1 檢查特殊元素 a as zx qw for er in a print you are er print nthe best you are as.you are zx.you are qw.the best asd as zx qw for a in ...