Files
yuyin_ios/SweetParty/主类/音悦新增/广播头条/SEARoomHeadlineShowView.m

102 lines
2.7 KiB
Mathematica
Raw Normal View History

2025-08-08 11:05:33 +08:00
//
// 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