HomeViewController.m 3.2 KB
//
//  HomeViewController.m
//  DreamSleep
//
//  Created by peter on 2022/4/1.
//

#import "HomeViewController.h"
#import "DSGifHeader.h"
#import "HomeTableView.h"

@interface HomeViewController ()
@property (nonatomic, strong) HomeTableView *homeTV;
@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.view = self.homeTV;
    
    // 导航栏背景色
//    self.navigationController.navigationBar.dk_barTintColorPicker = DKColorPickerWithKey(NaviBG);
    
    // leftItem
    UILabel *leftLab = [[UILabel alloc] init];
    leftLab.text = @"小梦睡眠";
    leftLab.dk_textColorPicker = DKColorPickerWithKey(TEXT);
    leftLab.font = [UIFont boldSystemFontOfSize:24.0];
    [leftLab sizeToFit];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftLab];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    // 隐藏导航栏分割线
//    self.navigationController.navigationBar.shadowImage = [UIImage new];
    
    // view背景色
//    self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
    
//    self.tableView.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
//        dispatch_after(2.0, dispatch_get_main_queue(), ^{
//            [self.tableView.mj_header endRefreshing];
//        });
//    }];
    
    // 设置导航栏返回按钮文字
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
                                             initWithTitle:@""
                                             style:UIBarButtonItemStylePlain
                                             target:self
                                             action:nil];
    // 设置导航栏返回按钮颜色
    self.navigationController.navigationBar.tintColor = DSWhite;
    // 设置导航栏背景色、title颜色、隐藏分割线
    NSDictionary *titleTextAttributes = @{NSForegroundColorAttributeName:ColorFromHex(0x333333)};
    if (@available(iOS 13.0, *)) {
        UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
        appearance.titleTextAttributes = titleTextAttributes;
        appearance.backgroundColor = DSWhite;
        appearance.shadowColor = [UIColor clearColor];
        self.navigationController.navigationBar.standardAppearance = appearance;
        self.navigationController.navigationBar.scrollEdgeAppearance = appearance;
    } else {
        self.navigationController.navigationBar.dk_barTintColorPicker = DKColorPickerWithKey(NaviBG);
        [self.navigationController.navigationBar setTitleTextAttributes:titleTextAttributes];
        self.navigationController.navigationBar.shadowImage = [UIImage new];
    }
}

//#pragma mark - Table view data source
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//    return 1;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"homeCell" forIndexPath:indexPath];
//    return cell;
//}

- (HomeTableView *)homeTV {
    if (!_homeTV) {
        _homeTV = [[HomeTableView alloc] initDemo];
    }
    return _homeTV;
}

@end