CNHintView.m 2.38 KB
//
//  CNHintView.m
//  CNLiveNetAdd
//
//  Created by CNLive on 2021/7/13.
//  Copyright © 2021 cnlive. All rights reserved.
//

#import "CNHintView.h"

@interface CNHintView ()
@property (nonatomic, strong)UILabel *titleLabel;
@property (nonatomic, strong)UILabel *MessageLabel;
@property (nonatomic, strong)UIButton *closeBtn;
@end

@implementation CNHintView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = kWhiteColor;
        self.layer.cornerRadius = 8;
        [self addSubview:self.titleLabel];
        [self addSubview:self.closeBtn];
        [self addSubview:self.MessageLabel];
        
    }
    return self;
}
#pragma mark - Action
-(void)closeBtnClick
{
    [self removeFromSuperview];
}

#pragma mark - Getting
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(CNScaleW(15), CNScaleW(15), 60*RATIO, 24*RATIO)];
        _titleLabel.text = @"小提示";
        _titleLabel.textColor = RGB(51, 51, 51);
        _titleLabel.font = UIFontCNMake(17);
        _titleLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _titleLabel;
}

-(UILabel *)MessageLabel
{
    if (!_MessageLabel) {
        _MessageLabel = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel.left, _titleLabel.bottom+CNScaleW(6), _closeBtn.right, 37*RATIO)];
        _MessageLabel.text = @"可以裁剪出人物上半身,脸部不要过小且无遮挡,尺寸请尽量保持4:4或16:9比例,能有效提升修复效果。";
        _MessageLabel.textColor = RGB(51, 51, 51);
        _MessageLabel.textAlignment = NSTextAlignmentLeft;
        _MessageLabel.numberOfLines = 0;
        _MessageLabel.font = UIFontCNMake(13);
        if ([_MessageLabel separatedLines].count >3) {
            _MessageLabel.font = UIFontCNMake(12);
        }
        [_MessageLabel sizeToFit];
    }
    return _MessageLabel;
}
- (UIButton *)closeBtn
{
    if (!_closeBtn) {
        _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _closeBtn.frame = CGRectMake(self.width - CNScaleW(15) -19*RATIO, _titleLabel.top, 19*RATIO, 19*RATIO);
        [_closeBtn setImage:[CNLiveCPhotoRepairImage getImageWithNamed:@"oldPho_tipClose"] forState:UIControlStateNormal];
        [_closeBtn addTarget:self action:@selector(closeBtnClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return  _closeBtn;
}
@end