@@ -18,6 +18,7 @@ @interface NEHTTPEyeViewController ()<UITableViewDataSource,UITableViewDelegate,
1818 UISearchBar *mySearchBar;
1919 UISearchDisplayController *mySearchDisplayController;
2020 NSArray *filterHTTPRequests;
21+ BOOL isiPhoneX;
2122}
2223
2324@end
@@ -28,11 +29,12 @@ - (void)viewDidLoad {
2829 [super viewDidLoad ];
2930 // Do any additional setup after loading the view.
3031
31-
32+ isiPhoneX = (([[UIScreen mainScreen ] bounds ].size .width == 375 .f && [[UIScreen mainScreen ] bounds ].size .height == 812 .f ) || ([[UIScreen mainScreen ] bounds ].size .height == 375 .f && [[UIScreen mainScreen ] bounds ].size .width == 812 .f ));
33+
3234 self.automaticallyAdjustsScrollViewInsets =NO ;
3335 self.view .backgroundColor =[UIColor whiteColor ];
3436
35- mainTableView=[[UITableView alloc ] initWithFrame: CGRectMake (0 , 0 , [[UIScreen mainScreen ] bounds ].size.width, [[UIScreen mainScreen ] bounds ].size.height-64 ) style: UITableViewStylePlain];
37+ mainTableView=[[UITableView alloc ] initWithFrame: CGRectMake (0 , 0 , [[UIScreen mainScreen ] bounds ].size.width, [[UIScreen mainScreen ] bounds ].size.height-64 -(isiPhoneX? 24: 0 ) ) style: UITableViewStylePlain];
3638 [self .view addSubview: mainTableView];
3739
3840 double flowCount=[[[NSUserDefaults standardUserDefaults ] objectForKey: @" flowCount" ] doubleValue ];
@@ -59,35 +61,35 @@ - (void)viewDidLoad {
5961 NSMutableAttributedString *attrText = [[NSMutableAttributedString alloc ] init ];
6062 [attrText appendAttributedString: titleString];
6163 [attrText appendAttributedString: flowCountString];
62- UILabel *titleText = [[UILabel alloc ] initWithFrame: CGRectMake (([[UIScreen mainScreen ] bounds ].size.width-120 )/2 , 20 , 120 , 44 )];
64+ UILabel *titleText = [[UILabel alloc ] initWithFrame: CGRectMake (([[UIScreen mainScreen ] bounds ].size.width-120 )/2 , 20 +(isiPhoneX? 24: 0 ) , 120 , 44 )];
6365 titleText.backgroundColor = [UIColor clearColor ];
6466 titleText.textColor =[UIColor whiteColor ];
6567 titleText.textAlignment =NSTextAlignmentCenter;
6668 titleText.numberOfLines =0 ;
6769 titleText.attributedText =attrText;
6870
6971 if ([self .navigationController viewControllers ].count <1 ) {
70- UINavigationBar *bar=[[UINavigationBar alloc ] initWithFrame: CGRectMake (0 , 0 , [[UIScreen mainScreen ] bounds ].size.width, 64 )];
72+ UIView *bar=[[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , [[UIScreen mainScreen ] bounds ].size.width, 64 +(isiPhoneX? 24: 0 ) )];
7173 [self .view addSubview: bar];
72- bar.barTintColor =[UIColor colorWithRed: 0 .24f green: 0 .51f blue: 0 .78f alpha: 1 .00f ];
74+ bar.backgroundColor =[UIColor colorWithRed: 0 .24f green: 0 .51f blue: 0 .78f alpha: 1 .00f ];
7375
7476
7577 UIButton *backBt=[UIButton buttonWithType: UIButtonTypeCustom];
76- backBt.frame =CGRectMake (10 , 27 , 40 , 30 );
78+ backBt.frame =CGRectMake (10 , 27 +(isiPhoneX? 24 : 0 ) , 40 , 30 );
7779 [backBt setTitle: @" back" forState: UIControlStateNormal];
7880 backBt.titleLabel .font =[UIFont systemFontOfSize: 15 ];
7981 [backBt setTitleColor: [UIColor whiteColor ] forState: UIControlStateNormal];
8082 [backBt addTarget: self action: @selector (backBtAction ) forControlEvents: UIControlEventTouchUpInside];
8183 [bar addSubview: backBt];
8284
8385 UIButton *settingsBt=[UIButton buttonWithType: UIButtonTypeCustom];
84- settingsBt.frame =CGRectMake ([[UIScreen mainScreen ] bounds ].size .width -60 , 27 , 50 , 30 );
86+ settingsBt.frame =CGRectMake ([[UIScreen mainScreen ] bounds ].size .width -60 , 27 +(isiPhoneX? 24 : 0 ) , 50 , 30 );
8587 [settingsBt setTitle: @" settings" forState: UIControlStateNormal];
8688 settingsBt.titleLabel .font =[UIFont systemFontOfSize: 13 ];
8789 [settingsBt setTitleColor: [UIColor whiteColor ] forState: UIControlStateNormal];
8890 [settingsBt addTarget: self action: @selector (rightAction ) forControlEvents: UIControlEventTouchUpInside];
8991 [bar addSubview: settingsBt];
90- mainTableView.frame =CGRectMake (0 , 64 , [[UIScreen mainScreen ] bounds ].size .width , [[UIScreen mainScreen ] bounds ].size .height -64 );
92+ mainTableView.frame =CGRectMake (0 , 64 +(isiPhoneX? 24 : 0 ) , [[UIScreen mainScreen ] bounds ].size .width , [[UIScreen mainScreen ] bounds ].size .height -64 -(isiPhoneX? 24 : 0 ) );
9193 [bar addSubview: titleText];
9294 }else {
9395 titleText.frame =CGRectMake (([[UIScreen mainScreen ] bounds ].size .width -120 )/2 , 0 , 120 , 44 );
@@ -200,7 +202,7 @@ - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
200202 }
201203 // 准备搜寻前,把上面调整的TableView调整回全屏幕的状态
202204 [UIView animateWithDuration: 0.2 animations: ^{
203- mainTableView.frame = CGRectMake (0 , 20 , [[UIScreen mainScreen ] bounds ].size .width , [[UIScreen mainScreen ] bounds ].size .height -20 );
205+ mainTableView.frame = CGRectMake (0 , 20 +(isiPhoneX? 24 : 0 ) , [[UIScreen mainScreen ] bounds ].size .width , [[UIScreen mainScreen ] bounds ].size .height -20 -(isiPhoneX? 24 : 0 ) );
204206
205207 }];
206208
@@ -213,7 +215,7 @@ - (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar {
213215 }
214216 if (searchBar.text .length <1 ) {
215217 [UIView animateWithDuration: 0.2 animations: ^{
216- mainTableView.frame = CGRectMake (0 , 64 , [[UIScreen mainScreen ] bounds ].size .width , [[UIScreen mainScreen ] bounds ].size .height -64 );
218+ mainTableView.frame = CGRectMake (0 , 64 +(isiPhoneX? 24 : 0 ) , [[UIScreen mainScreen ] bounds ].size .width , [[UIScreen mainScreen ] bounds ].size .height -64 -(isiPhoneX? 24 : 0 ) );
217219 }];
218220 }
219221 // 当按下search按钮后 后走这里,并且这之后按cancel按钮不会走这里;当没有按过search按钮,按cancel按钮会走这里
0 commit comments