//
|
// BaseViewController.m
|
// BuWanVideo2.0
|
//
|
// Created by apple on 2018/3/13.
|
// Copyright © 2018年 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "BaseViewController.h"
|
#import "LookNoteController.h"
|
#import "searchViewController.h"
|
@interface BaseViewController ()
|
@property (nonatomic , strong) NSMutableArray *dataHot;//热门搜索
|
@property (nonatomic , strong) UITextField *searchText;//搜索框
|
|
@end
|
|
@implementation BaseViewController
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
|
}
|
- (void)viewWillAppear:(BOOL)animated{
|
// self.navigationController.navigationBar.translucent = NO;
|
self.dataHot = @[].mutableCopy;
|
[self getHotSearch];
|
[self loadNavigationbar];
|
|
}
|
-(void)loadNavigationbar{
|
//去掉titlie
|
UIView *tview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0.01, 0.01)];
|
self.navigationItem.titleView = tview;
|
|
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
|
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
|
// 创建一个高20的假状态栏
|
UIView *statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, -20, KScreenW, 20)];
|
// CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
|
// statusBarView.frame = statusBarFrame;
|
if (KIsiPhoneX) {
|
statusBarView.frame = CGRectMake(0, -44, KScreenW, 44);
|
}
|
NSLog(@"%f == %f \n %f === %f",KScreenH,KScreenW,[[UIScreen mainScreen] currentMode].size.height,[[UIScreen mainScreen] currentMode].size.width);
|
// 设置颜色
|
statusBarView.backgroundColor = [UIColor whiteColor];
|
//[self.navigationController.navigationBar setBackgroundColor:kGlobalMainColor];
|
|
[self.navigationController.navigationBar addSubview:statusBarView];
|
//搜索
|
UIView *seachView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenW / 5 * 4, 30)];
|
self.searchText = [[UITextField alloc]initWithFrame:CGRectMake(0, 0,seachView.frame.size.width, seachView.frame.size.height)];
|
self.searchText.backgroundColor = [UIColor colorWithWhite:0.7 alpha:0.2];
|
self.searchText.layer.cornerRadius = self.searchText.frame.size.height / 2;
|
self.searchText.textColor = [UIColor whiteColor];
|
self.searchText.font = [UIFont systemFontOfSize:14];
|
UIView *leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 45, 25)];
|
UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(10, 3, 19, 19)];
|
imageview.image = [UIImage imageNamed:@"搜索"];
|
[leftView addSubview:imageview];
|
self.searchText.leftView = leftView;
|
self.searchText.leftViewMode = UITextFieldViewModeAlways;
|
UIButton *textButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
textButton.frame = CGRectMake(0, 0,seachView.frame.size.width, seachView.frame.size.height);
|
[textButton addTarget:self action:@selector(JumpToSearchView) forControlEvents:UIControlEventTouchUpInside];
|
[seachView addSubview:self.searchText];
|
|
[seachView addSubview:textButton];
|
UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithCustomView:seachView];
|
|
//观看记录
|
UIButton *recordBtn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
|
[recordBtn setImage:[UIImage imageNamed:@"历史记录"] forState:UIControlStateNormal];
|
[recordBtn addTarget:self action:@selector(JumpToRecordView) forControlEvents:UIControlEventTouchUpInside];
|
UIBarButtonItem *recordBarItem=[[UIBarButtonItem alloc] initWithCustomView:recordBtn];
|
// //下载
|
// UIButton *downLoadBtn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
|
// downLoadBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 4, 0, 4);
|
// [downLoadBtn setImage:[UIImage imageNamed:@"缓存"] forState:UIControlStateNormal];
|
// [downLoadBtn addTarget:self action:@selector(JumpToDownloadView) forControlEvents:UIControlEventTouchUpInside];
|
// UIBarButtonItem *downLoadBarItem=[[UIBarButtonItem alloc] initWithCustomView:downLoadBtn];
|
//搜索
|
// UIButton *SearchBtn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
|
// [SearchBtn setImage:[UIImage imageNamed:@"搜索"] forState:UIControlStateNormal];
|
// [SearchBtn addTarget:self action:@selector(JumpToSearchView) forControlEvents:UIControlEventTouchUpInside];
|
// UIBarButtonItem *SearchBarItem=[[UIBarButtonItem alloc] initWithCustomView:SearchBtn];
|
//空白间距
|
UILabel *WhiteLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 8, 10)];
|
WhiteLabel.backgroundColor=[UIColor clearColor];
|
UIBarButtonItem *WhiteBarItem=[[UIBarButtonItem alloc] initWithCustomView:WhiteLabel];
|
|
UILabel *WhiteLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 20, 10)];
|
WhiteLabel1.backgroundColor=[UIColor clearColor];
|
UIBarButtonItem *WhiteBarItem1=[[UIBarButtonItem alloc] initWithCustomView:WhiteLabel1];
|
//添加 观看记录/下载/搜索 到导航栏
|
self.navigationItem.rightBarButtonItems=[[NSArray alloc] initWithObjects:recordBarItem,searchItem,WhiteBarItem,nil];
|
}
|
/**
|
* 跳转到历史记录
|
*/
|
-(void)JumpToRecordView{
|
LookNoteController *LookNoteLookNoteVC=[[LookNoteController alloc] init];
|
[LookNoteLookNoteVC setHidesBottomBarWhenPushed:YES];
|
|
[self.navigationController pushViewController:LookNoteLookNoteVC animated:YES];
|
}
|
|
/**
|
* 跳转到搜索
|
*/
|
-(void)JumpToSearchView{
|
searchViewController *searchVC=[[searchViewController alloc] init];
|
[searchVC setHidesBottomBarWhenPushed:YES];
|
|
[self.navigationController pushViewController:searchVC animated:YES];
|
}
|
|
- (void)getHotSearch{
|
[[YTHNetInterface startInterface] getHotSerachWithUid:[YTHsharedManger startManger].Uid withSystem:@"1" withblock:^(BOOL isSuccessful, id result, NSString *error) {
|
if (isSuccessful) {
|
NSDictionary *dic = (NSDictionary *)result;
|
if (!_dataHot) {
|
_dataHot = [[NSMutableArray alloc] initWithCapacity:0];
|
}
|
[_dataHot removeAllObjects];
|
NSArray *ar = [[dic objectForKey:@"Data"] objectForKey:@"data"];
|
for (int i =0; i<ar.count; i++) {
|
[_dataHot addObject:[ar objectAtIndex:i]];
|
}
|
NSLog(@"////%@'''''",_dataHot);
|
if ([YTHsharedManger startManger].searchTitle.length == 0) {
|
NSInteger rand = arc4random()%self.dataHot.count ;
|
self.searchText.text = self.dataHot[rand];
|
[YTHsharedManger startManger].searchTitle = self.searchText.text;
|
}else{
|
self.searchText.text = [YTHsharedManger startManger].searchTitle;
|
}
|
//刷新热门搜索
|
}else{
|
//显示网络连接失败
|
}
|
}];
|
}
|
|
|
- (void)didReceiveMemoryWarning {
|
[super didReceiveMemoryWarning];
|
// Dispose of any resources that can be recreated.
|
}
|
|
|
@end
|