// // AWM_ForMyViewController.m #import "AWM_ForMyViewController.h" #import "AWM_wallpaperViewController.h" #import "AWM_UserPravcyVC.h" #define WPScreen_w [UIScreen mainScreen].bounds.size.width #define WPScreen_h [UIScreen mainScreen].bounds.size.height #define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f] @interface AWM_ForMyViewController () @end @implementation AWM_ForMyViewController - (void)viewDidLoad { [super viewDidLoad]; UIImageView *bgImage = [[UIImageView alloc] initWithFrame:self.view.bounds]; NSString *greeting = KLS(@"bg", @"A friendly greeting"); bgImage.image = [UIImage imageNamed:greeting]; bgImage.userInteractionEnabled = YES; [self.view addSubview:bgImage]; UIImageView *iconImage = [[UIImageView alloc] initWithFrame:CGRectMake((WPScreen_w-150)/2, 150, 150, 150)]; NSString *my1 = KLS(@"my1", @"A friendly greeting"); NSString *my2 = KLS(@"my2", @"A friendly greeting"); NSString *my3 = KLS(@"my3", @"A friendly greeting"); NSString *my4 = KLS(@"my4", @"A friendly greeting"); NSString *my0 = KLS(@"my0", @"A friendly greeting"); iconImage.image = [UIImage imageNamed:my0]; iconImage.userInteractionEnabled = YES; [self.view addSubview:iconImage]; NSArray *icons = @[my1,my2,my3,my4]; for (int i = 0; i < 4; i ++) { UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake((WPScreen_w-280)/2+i%2*(150), 350+i/2*(150), 130, 130)]; [btn setImage:[UIImage imageNamed:icons[i]] forState:UIControlStateNormal]; // btn.layer.cornerRadius = 5; // btn.layer.masksToBounds = YES; btn.tag = i; [btn addTarget:self action:@selector(iconEvent:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; } UIButton *pracy_btn = [UIButton new]; [self.view addSubview:pracy_btn]; [pracy_btn addTarget:self action:@selector(showUserPravcy) forControlEvents:UIControlEventTouchUpInside]; NSString *privacy = KLS(@"privacy", @"A friendly greeting"); [pracy_btn setTitle:privacy forState:UIControlStateNormal]; [pracy_btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; pracy_btn.titleLabel.font = [UIFont systemFontOfSize:14]; CGFloat btn_w = 90; CGFloat btn_h = 20; pracy_btn.frame = CGRectMake((WPScreen_w - btn_w) * .5, WPScreen_h - btn_h - 90, btn_w, btn_h); } //显示用户隐私 - (void)showUserPravcy { AWM_UserPravcyVC *vc = [AWM_UserPravcyVC new]; [self.navigationController pushViewController:vc animated:YES]; } - (void)iconEvent:(UIButton *)icon{ if (icon.tag == 0) { AWM_wallpaperViewController *wpdetail = [[AWM_wallpaperViewController alloc] init]; [self.navigationController pushViewController:wpdetail animated:YES]; }else if (icon.tag == 2){ UIAlertView *iconAl = [[UIAlertView alloc] initWithTitle:@"" message:@"Clean Success" delegate:self cancelButtonTitle:nil otherButtonTitles:@"ok", nil]; [iconAl show]; }else if (icon.tag == 1){ [self openAppStoreDirectlyWithAppID:@"6502616689"]; } } - (void)openAppStoreDirectlyWithAppID:(NSString *)appID { NSString *appStoreLink = [NSString stringWithFormat:@"https://apps.apple.com/app/id%@", appID]; NSURL *url = [NSURL URLWithString:appStoreLink]; if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; } else { NSLog(@"Cannot open App Store link."); } } @end