Files
mier_ios/SweetParty/主类/音悦新增/盲盒巡乐会/BlindXunlehuiShowView.m
2025-08-11 10:43:19 +08:00

48 lines
1.3 KiB
Objective-C

//
// BlindXunlehuiShowView.m
// SweetParty
//
// Created by yons on 2024/12/28.
//
#import "BlindXunlehuiShowView.h"
@interface BlindXunlehuiShowView ()
@property (nonatomic, assign)CGPoint originalPoint;
@end
@implementation BlindXunlehuiShowView
- (void)awakeFromNib {
[super awakeFromNib];
[_leftTimeL styleGradiBlueColor];
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onTuodong:)];
[self addGestureRecognizer:pan];
}
- (IBAction)onClose:(id)sender {
[self removeFromSuperview];
}
//滑动事件
- (void)onTuodong:(UIPanGestureRecognizer *)pan{
//获取当前位置
CGPoint currentPosition = [pan locationInView:self];
if (pan.state == UIGestureRecognizerStateBegan) {
_originalPoint = currentPosition;
}else if(pan.state == UIGestureRecognizerStateChanged){
//偏移量(当前坐标 - 起始坐标 = 偏移量)
CGFloat offsetX = currentPosition.x - _originalPoint.x;
CGFloat offsetY = currentPosition.y - _originalPoint.y;
//移动后的按钮中心坐标
CGFloat centerX = self.center.x + offsetX;
CGFloat centerY = self.center.y + offsetY;
self.center = CGPointMake(centerX, centerY);
}
}
@end