//
//  customLaunchView.m
//  隐私保护
//
//  Created by xd h on 2023/10/12.
//

#import "customLaunchView.h"


@implementation customLaunchView

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    
    [self drawAnyView];
    
    return self;
}

-(void)drawAnyView
{
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
    imageView.image = [UIImage imageNamed:@"login_bg"];
    [self addSubview:imageView];
    
    UIImageView *imageView111 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
    
    [self addSubview:imageView111];
    
    //NSString *preferredLanguage = [[[NSBundle mainBundle] preferredLocalizations] firstObject];
    ///获取设备当前地区的代码和APP语言环境
    NSString *languageCode = [NSLocale preferredLanguages][0];
  
    NSString *imageNameStr = @"customLaunch_en";
    
    //if([languageCode isEqualToString:@"zh-Hans-US"])
    if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
    {
        imageNameStr = @"customLaunch_Hans";
    }
    //else if([languageCode isEqualToString:@"zh-Hant-HK"])
    else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
    {
        imageNameStr = @"customLaunch_Hans_HK";
    }
    //else if([languageCode isEqualToString:@"ja-US"])
    else if([languageCode rangeOfString:@"ja-"].location != NSNotFound)
    {
        imageNameStr = @"customLaunch_ja";
    }
    
    imageView111.image = [UIImage imageNamed:imageNameStr];
    
    [imageView111 mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(375.0);
        make.height.mas_equalTo(320.0);
    }];
}
@end
