Переглянути джерело

Settings: Style tableview section header

Mike JS. Choi 7 роки тому
батько
коміт
d59f276c23
1 змінених файлів з 28 додано та 1 видалено
  1. 28 1
      Sources/VLCSettingsController.m

+ 28 - 1
Sources/VLCSettingsController.m

@@ -18,6 +18,9 @@
 #import <LocalAuthentication/LocalAuthentication.h>
 #import "VLC_iOS-Swift.h"
 
+CGFloat const SETTINGS_HEADER_HEIGHT = 64.;
+NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderViewIdentifier";
+
 @interface VLCSettingsController ()<PAPasscodeViewControllerDelegate>
 @end
 
@@ -44,16 +47,18 @@
     
     self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_ABOUT", nil) style:UIBarButtonItemStylePlain target:self action:@selector(showAbout)];
     self.navigationItem.leftBarButtonItem.accessibilityIdentifier = VLCAccessibilityIdentifier.about;
-    
+
     self.neverShowPrivacySettings = YES;
     self.tableView.estimatedRowHeight = 100;
     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
     self.tableView.rowHeight = UITableViewAutomaticDimension;
+    [self.tableView registerClass:[VLCSectionTableHeaderView class] forHeaderFooterViewReuseIdentifier:kVLCSectionTableHeaderViewIdentifier];
     [self themeDidChange];
 }
 
 - (void)themeDidChange
 {
+
     self.view.backgroundColor = PresentationTheme.current.colors.background;
     [self setNeedsStatusBarAppearanceUpdate];
 }
@@ -177,4 +182,26 @@
     }
 }
 
+#pragma mark - InAppSettings customization
+
+- (CGFloat)settingsViewController:(id<IASKViewController>)settingsViewController tableView:(UITableView *)tableView heightForHeaderForSection:(NSInteger)section
+{
+    return section == 0. ? 0. : SETTINGS_HEADER_HEIGHT;
+}
+
+- (UIView *)settingsViewController:(id<IASKViewController>)settingsViewController tableView:(UITableView *)tableView viewForHeaderForSection:(NSInteger)section
+{
+    if (section == 0) {
+        return nil;
+    }
+    VLCSectionTableHeaderView *header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:kVLCSectionTableHeaderViewIdentifier];
+    header.textLabel.text = [self.settingsReader titleForSection:section];
+    return header;
+}
+
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
+{
+    return nil;
+}
+
 @end