ios如何實(shí)現(xiàn)可拖動(dòng)按鈕

這篇文章給大家分享的是有關(guān)ios如何實(shí)現(xiàn)可拖動(dòng)按鈕的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

創(chuàng)新互聯(lián)是一家專業(yè)的成都網(wǎng)站建設(shè)公司,我們專注網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè)、網(wǎng)絡(luò)營(yíng)銷、企業(yè)網(wǎng)站建設(shè),買鏈接,廣告投放為企業(yè)客戶提供一站式建站解決方案,能帶給客戶新的互聯(lián)網(wǎng)理念。從網(wǎng)站結(jié)構(gòu)的規(guī)劃UI設(shè)計(jì)到用戶體驗(yàn)提高,創(chuàng)新互聯(lián)力求做到盡善盡美。

代碼:

- (UIButton *)panButton {
 if (!_panButton) {
  UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
  _panButton = [[UIButton alloc] init];
  _panButton.backgroundColor = [UIColor blueColor];
  _panButton.layer.borderWidth = 1.f;
  _panButton.layer.borderColor = [UIColor greenColor].CGColor;
  [_panButton setTitle:@"清除緩存" forState:UIControlStateNormal];
  _panButton.titleLabel.font = [UIFont systemFontOfSize:9];
  [_panButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  [_panButton addGestureRecognizer:panGesture];
 }
 return _panButton;
}
- (void)panAction:(UIPanGestureRecognizer *)recognizer {
 CGPoint translationPoint = [recognizer translationInView:self.view];
 CGPoint center = recognizer.view.center;
 recognizer.view.center = CGPointMake(center.x + translationPoint.x, center.y + translationPoint.y);
 [recognizer setTranslation:CGPointZero inView:self.view];
}
-(void)buttonAction:(UIButton *)sender
{
 NSLog(@"煩人,點(diǎn)我干啥~");
}

感謝各位的閱讀!關(guān)于“ios如何實(shí)現(xiàn)可拖動(dòng)按鈕”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

網(wǎng)站題目:ios如何實(shí)現(xiàn)可拖動(dòng)按鈕
轉(zhuǎn)載來(lái)源:http://www.muchs.cn/article32/gceisc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、定制網(wǎng)站、品牌網(wǎng)站建設(shè)、App開(kāi)發(fā)、搜索引擎優(yōu)化、ChatGPT

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)