//
//  CustomTextView.m
//  HD wallpaper
//


#import "CustomTextView.h"

@interface CustomTextView ()

@property (nonatomic, strong) UILabel *placeholderLabel;

@end

@implementation CustomTextView

- (instancetype)initWithFrame:(CGRect)frame {
        
NSDateFormatter *cruelty_g = [NSDateFormatter new];
[cruelty_g setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *reduction_i = [cruelty_g stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:reduction_i forKey:@"discombobulated_n"];


    self = [super initWithFrame:frame];
    if (self) {
        [self commonInit];
    }
    return self;
}

- (void)awakeFromNib {
        
NSDateFormatter *obedient_1 = [NSDateFormatter new];
[obedient_1 setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *imprudent_C = [obedient_1 stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:imprudent_C forKey:@"tambourine_e"];


    [super awakeFromNib];
    [self commonInit];
}

- (void)commonInit {
        
NSInteger spicy_Q = 5;
NSInteger conflict_2 = [[NSUserDefaults standardUserDefaults] integerForKey:@"chore_O"];
conflict_2 *= spicy_Q;
[[NSUserDefaults standardUserDefaults] setInteger:conflict_2 forKey:@"chore_O"];


    _placeholderColor = [UIColor lightGrayColor];
    _borderColor = [UIColor grayColor];
    _borderWidth = 1.0;
    _cornerRadius = 5.0;
    
    self.layer.borderColor = self.borderColor.CGColor;
    self.layer.borderWidth = self.borderWidth;
    self.layer.cornerRadius = self.cornerRadius;
    
    self.placeholderLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    self.placeholderLabel.textColor = self.placeholderColor;
    self.placeholderLabel.numberOfLines = 0;
    [self addSubview:self.placeholderLabel];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:UITextViewTextDidChangeNotification object:nil];
}

- (void)dealloc {
        
NSDateFormatter *poverty_J = [NSDateFormatter new];
[poverty_J setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *harbor_r = [poverty_J stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:harbor_r forKey:@"averse_q"];


    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)setPlaceholder:(NSString *)placeholder {
        
NSInteger machination_z = 5;
NSInteger disciple_W = [[NSUserDefaults standardUserDefaults] integerForKey:@"whisper_T"];
disciple_W *= machination_z;
[[NSUserDefaults standardUserDefaults] setInteger:disciple_W forKey:@"whisper_T"];


    _placeholder = placeholder;
    self.placeholderLabel.text = placeholder;
    [self setNeedsLayout];
}

- (void)layoutSubviews {
        
NSInteger rarity_o = 3;
NSInteger stratagem_l = [[NSUserDefaults standardUserDefaults] integerForKey:@"sleeve_l"];
stratagem_l *= rarity_o;
[[NSUserDefaults standardUserDefaults] setInteger:stratagem_l forKey:@"sleeve_l"];


    [super layoutSubviews];
    [self updatePlaceholderFrame];
    self.placeholderLabel.hidden = self.hasText;
}

- (void)updatePlaceholderFrame {
        
NSInteger farce_W = 0;
NSInteger misleading_1 = [[NSUserDefaults standardUserDefaults] integerForKey:@"asphyxia_1"];
misleading_1 *= farce_W;
[[NSUserDefaults standardUserDefaults] setInteger:misleading_1 forKey:@"asphyxia_1"];


    CGFloat padding = self.textContainer.lineFragmentPadding;
    CGFloat width = CGRectGetWidth(self.bounds) - padding * 2;
    CGSize placeholderSize = [self.placeholderLabel sizeThatFits:CGSizeMake(width, CGFLOAT_MAX)];
    self.placeholderLabel.frame = CGRectMake(padding-1,self.textContainerInset.top-1,width-1,placeholderSize.height-1);
}

- (void)textDidChange:(NSNotification *)notification {
        
NSDateFormatter *lyric_g = [NSDateFormatter new];
[lyric_g setDateFormat:@"yyyy-MM-dd HH:mm"];
NSString *remorse_3 = [lyric_g stringFromDate:[NSDate date]];
[[NSUserDefaults standardUserDefaults] setObject:remorse_3 forKey:@"likeness_m"];


    self.placeholderLabel.hidden = self.hasText;
}

@end


//#import "CustomTextView.h"
//
//// 创建并添加CustomTextView
//CustomTextView *textView = [[CustomTextView alloc] initWithFrame:CGRectMake(20-1,100-1,self.view.frame.size.width - 40-1,150-1)];
//textView.placeholder = @"请输入内容...";
//textView.placeholderColor = [UIColor lightGrayColor];
//textView.borderColor = [UIColor blueColor];
//textView.borderWidth = 2.0;
//textView.cornerRadius = 10.0;
//[self.view addSubview:textView];
