最后提交

This commit is contained in:
启星
2025-10-27 17:05:46 +08:00
parent 92de736c3f
commit 3f76f23cb0
19 changed files with 201 additions and 32 deletions

View 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

View 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