109 lines
2.8 KiB
Objective-C
109 lines
2.8 KiB
Objective-C
//
|
|
// SessionAudioRecordView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/4/21.
|
|
//
|
|
|
|
#import "SessionAudioRecordView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
|
|
|
|
@interface SessionAudioRecordView ()
|
|
///背景
|
|
@property (nonatomic,strong) UIView * backView;
|
|
///显示图片
|
|
@property (nonatomic,strong) UIImageView *logoImageView;
|
|
///显示标题
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
@end
|
|
|
|
@implementation SessionAudioRecordView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
#pragma mark - Public Method
|
|
- (void)configAudioRecord:(NSString *)imageName title:(NSString *)title isAnimation:(BOOL)isAnimation {
|
|
self.logoImageView.image = [UIImage imageNamed:imageName];
|
|
if (isAnimation) {
|
|
[self.logoImageView startAnimating];
|
|
} else {
|
|
[self.logoImageView stopAnimating];
|
|
}
|
|
self.titleLabel.text = title;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self addSubview:self.backView];
|
|
[self.backView addSubview:self.logoImageView];
|
|
[self.backView addSubview:self.titleLabel];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(250, 200));
|
|
}];
|
|
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self);
|
|
}];
|
|
|
|
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self.backView);
|
|
make.top.mas_equalTo(self.backView).offset(50);
|
|
make.size.mas_equalTo(CGSizeMake(90, 72));
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.backView);
|
|
make.top.mas_equalTo(self.logoImageView.mas_bottom).offset(25);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (UIView *)backView {
|
|
if (!_backView) {
|
|
_backView = [[UIView alloc] init];
|
|
_backView.backgroundColor = [UIColor blackColor];
|
|
_backView.layer.masksToBounds = YES;
|
|
_backView.layer.cornerRadius = 10;
|
|
}
|
|
return _backView;
|
|
}
|
|
|
|
|
|
- (UIImageView *)logoImageView {
|
|
if (!_logoImageView) {
|
|
_logoImageView = [[UIImageView alloc] init];
|
|
_logoImageView.userInteractionEnabled = YES;
|
|
UIImage *firstImage = [UIImage imageNamed:@"message_tool_audio_record_first"];
|
|
UIImage *secondImage = [UIImage imageNamed:@"message_tool_audio_record_second"];
|
|
UIImage *thirdImage = [UIImage imageNamed:@"message_tool_audio_record_third"];
|
|
_logoImageView.animationImages = @[firstImage, secondImage, thirdImage];
|
|
_logoImageView.animationDuration = 1;
|
|
_logoImageView.animationRepeatCount = HUGE;
|
|
}
|
|
return _logoImageView;
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.font = [UIFont systemFontOfSize:15];
|
|
_titleLabel.textColor = [UIColor whiteColor];
|
|
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
|
|
@end
|