最后提交
This commit is contained in:
16
QXLive/Room(房间)/View/每日任务/QXRoomDayTaskTagView.h
Normal file
16
QXLive/Room(房间)/View/每日任务/QXRoomDayTaskTagView.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// QXRoomDayTaskTagView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/27.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXRoomDayTaskTagView : UIView
|
||||
@property (nonatomic,copy)void(^startBlock)(void);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
64
QXLive/Room(房间)/View/每日任务/QXRoomDayTaskTagView.m
Normal file
64
QXLive/Room(房间)/View/每日任务/QXRoomDayTaskTagView.m
Normal file
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// QXRoomDayTaskTagView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/27.
|
||||
//
|
||||
|
||||
#import "QXRoomDayTaskTagView.h"
|
||||
@interface QXRoomDayTaskTagView()
|
||||
@property (nonatomic,strong)UIImageView *imageView;
|
||||
@property (nonatomic,strong)UILabel *timeLabel;
|
||||
@property (nonatomic,strong)UIButton *btn;
|
||||
@end
|
||||
@implementation QXRoomDayTaskTagView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(SCREEN_WIDTH-80, SCREEN_HEIGHT-330, 80, 60);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)initSubviews{
|
||||
self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_day_task"]];
|
||||
self.imageView.frame = CGRectMake(0, 0, 80, 60);
|
||||
[self addSubview:self.imageView];
|
||||
|
||||
self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.imageView.bottom, self.width, 20)];
|
||||
self.timeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.timeLabel.font = [UIFont systemFontOfSize:12];
|
||||
self.timeLabel.textColor = RGB16(0xFFEBBD);
|
||||
[self addSubview:self.timeLabel];
|
||||
self.btn = [[UIButton alloc] initWithFrame:self.bounds];
|
||||
[self.btn addTarget:self action:@selector(btnClick) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.btn];
|
||||
|
||||
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
|
||||
[self addGestureRecognizer:panRecognizer];
|
||||
}
|
||||
-(void)btnClick{
|
||||
if (self.startBlock) {
|
||||
self.startBlock();
|
||||
}
|
||||
}
|
||||
-(void)handlePan:(UIPanGestureRecognizer*)recognizer{
|
||||
if (recognizer.state == UIGestureRecognizerStateEnded) {
|
||||
NSLog(@"拖动结束");
|
||||
}
|
||||
CGPoint translation = [recognizer translationInView:self.viewController.view];
|
||||
CGPoint panCenter = CGPointMake(recognizer.view.center.x + translation.x,
|
||||
recognizer.view.center.y + translation.y);
|
||||
if (panCenter.y < kSafeAreaTop || panCenter.y> SCREEN_HEIGHT-kSafeAreaBottom) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
recognizer.view.center = CGPointMake(SCREEN_WIDTH-ScaleWidth(80)/2,
|
||||
recognizer.view.center.y + translation.y);
|
||||
[recognizer setTranslation:CGPointZero inView:self.viewController.view];
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user