102 lines
2.7 KiB
Objective-C
102 lines
2.7 KiB
Objective-C
//
|
|
// SEARoomHeadlineShowView.m
|
|
// romantic
|
|
//
|
|
// Created by Xmac on 2024/5/28.
|
|
// Copyright © 2024 romantic. All rights reserved.
|
|
//
|
|
|
|
#import "SEARoomHeadlineShowView.h"
|
|
|
|
@interface SEARoomHeadlineShowView ()
|
|
|
|
@property (nonatomic, assign)CGPoint originalPoint;
|
|
@property (nonatomic, assign) NSInteger status;
|
|
|
|
@end
|
|
|
|
@implementation SEARoomHeadlineShowView
|
|
|
|
- (void)awakeFromNib
|
|
{
|
|
[super awakeFromNib];
|
|
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onTuodong:)];
|
|
[self addGestureRecognizer:pan];
|
|
|
|
self.status = 1;
|
|
WEAK_SELF;
|
|
[self dg_Tapped:^{
|
|
if (weakSelf.status == 2){
|
|
self.status = 1;
|
|
weakSelf.baseCover.hidden = NO;
|
|
weakSelf.smallIcon.hidden = YES;
|
|
if (self.x >= (APPW-280)){
|
|
self.frame = CGRectMake(APPW-300, self.y, 300, 270);
|
|
}else{
|
|
self.frame = CGRectMake(0, self.y, 300, 270);
|
|
}
|
|
}
|
|
}];
|
|
}
|
|
|
|
|
|
- (IBAction)qiangButtonClick:(UIButton *)sender {
|
|
if (self.goBlock) {
|
|
self.goBlock();
|
|
}
|
|
}
|
|
|
|
- (IBAction)caifangButtonClick:(UIButton *)sender {
|
|
if (self.caiBlock){
|
|
self.caiBlock(_model.rid);
|
|
}
|
|
}
|
|
|
|
|
|
- (void)setModel:(SEARoomHeadlineModel *)model
|
|
{
|
|
_model = model;
|
|
[self.headerPic sd_setImageWithURL:[NSURL URLWithString:model.head_pic] placeholderImage:kDefaultUserIcon];
|
|
self.nicknameLabel.text = model.nick_name;
|
|
self.contentLabel.text = model.content;
|
|
}
|
|
|
|
//滑动事件
|
|
- (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);
|
|
}
|
|
else if(pan.state == UIGestureRecognizerStateEnded){
|
|
|
|
if (self.status == 2){
|
|
//小图标保持松开就吸附
|
|
if (self.x >= (APPW/2)){
|
|
self.frame = CGRectMake(APPW-60-15, self.y, 60, 60);
|
|
}else {
|
|
self.frame = CGRectMake(0, self.y, 60, 60);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
- (IBAction)closeButtonClick:(UIButton *)sender {
|
|
self.frame = CGRectMake(0, self.y, 60, 60);
|
|
self.baseCover.hidden = YES;
|
|
self.smallIcon.hidden = NO;
|
|
self.status = 2;
|
|
}
|
|
|
|
|
|
@end
|