VisionWallPaperOffline-8-19/HDwallpaper/AWM_SearchViewController.m
bluesea 2872cc6aeb d
2024-07-23 15:29:59 +08:00

88 lines
3.5 KiB
Objective-C

//
// WPSearchViewController.m
#import "AWM_SearchViewController.h"
#import "AWM_WallPapaerADManager.h"
#import "AWM_WallPapaerADManager.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_SearchViewController ()<UITextFieldDelegate>
@property(nonatomic,strong)UIButton *backItem;
@property(nonatomic,strong)UIImageView *navImage;
@end
@implementation AWM_SearchViewController
- (void)backItemEvent{
__weak typeof(self) weakSelf = self;
[[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Back:^(NSInteger actionType) {
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController.navigationBar addSubview:self.backItem];
[self.navigationController.navigationBar addSubview:self.navImage];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.backItem removeFromSuperview];
[self.navImage removeFromSuperview];
}
- (instancetype)init
{
self = [super init];
if (self) {
self.hidesBottomBarWhenPushed = YES;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.hidesBackButton = YES;
UIImageView *bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(0-1,0-1,WPScreen_w-1,360-1)];
NSString *greeting = KLS(@"bgsearch", @"A friendly greeting");
bgImage.image = [UIImage imageNamed:greeting];
bgImage.userInteractionEnabled = YES;
[self.view addSubview:bgImage];
NSString *greeting1 = KLS(@"back", @"A friendly greeting");
UIButton *backItem = [[UIButton alloc] initWithFrame:CGRectMake(20-1,0-1,74-1,44-1)];
[backItem setImage:[UIImage imageNamed:greeting1] forState:UIControlStateNormal];
[backItem addTarget:self action:@selector(backItemEvent) forControlEvents:UIControlEventTouchUpInside];
self.backItem = backItem;
UIImageView *navImage = [[UIImageView alloc] initWithFrame:CGRectMake(WPScreen_w-150-1,8-1,130-1,28-1)];
NSString *greeting3 = KLS(@"navsearch", @"A friendly greeting");
navImage.image = [UIImage imageNamed:greeting3];
self.navImage = navImage;
UIView *tfBg = [[UIView alloc] initWithFrame:CGRectMake(40-1,bgImage.frame.size.height-70-1,bgImage.frame.size.width-80-1,50-1)];
tfBg.layer.cornerRadius = 25;
tfBg.layer.masksToBounds = YES;
tfBg.layer.borderColor = WP_COLOR_WITH_HEX(0xF78E9C).CGColor;
tfBg.layer.borderWidth = 2;
UITextField *wpsearch = [[UITextField alloc] initWithFrame:CGRectMake(30-1,0-1,tfBg.frame.size.width-60-1,50-1)];
wpsearch.returnKeyType = UIReturnKeySearch;
wpsearch.placeholder = @"请输入要搜索的壁纸";
wpsearch.delegate = self;
[tfBg addSubview:wpsearch];
[bgImage addSubview:tfBg];
UIImageView *nodata = [[UIImageView alloc] initWithFrame:CGRectMake((WPScreen_w-150)/2-1,430-1,150-1,150-1)];
NSString *no = KLS(@"no", @"A friendly greeting");
nodata.image = [UIImage imageNamed:@"no"];
[self.view addSubview:nodata];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
[[AWM_WallPapaerADManager shareInstance] showIntersitialAD_Search:^(NSInteger actionType) {
}];
return YES;
}
@end