UITableView to modify the font size of its own retrieval column

Keywords: Attribute encoding C

UITableView can't be modified by using its own retrieval column. How to modify it?

Get UITableViewIndex before HeaderView will display


-(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
    for (UIView *view in [tableView subviews]) {
        if ([view isKindOfClass:[NSClassFromString(@"UITableViewIndex") class]]) {
           // Set font size
            [view setValue:FontSize forKey:@"_font"];
           //Set the size of the view
            view.bounds = CGRectMake(0, 0, 30, 30);
            //Setting only one of them is invalid
        }
    }

}

Details of UITableViewIndex property

titles      //Unknown attribute
font       //font size
drawingInsets  //Expand the scope
indexColor  //Font color
indexBackgroundColor //background color 
indexTrackingBackgroundColor 
selectedSection  //Select and so on
selectedSectionTitle  //Guess test indexTitle
pastTop 
pastBottom

Get all properties of UITableViewIndex at runtime
If you need to check the following code to obtain

            // Get all properties of the current class
            unsigned int count;// Number of record properties
            objc_property_t *properties = class_copyPropertyList([view class], &count);
            // ergodic
            for (int i = 0; i < count; i++) {
                
                // An opaque type that represents an Objective-C declared property.
                // objc_property_t attribute type
                objc_property_t property = properties[i];
                // Get the name of the property C language string
                const char *cName = property_getName(property);
                // Convert to Objective C string
                NSString *name = [NSString stringWithCString:cName encoding:NSUTF8StringEncoding];
                NSLog(@"%@",name);
            }
Guess the principle of UITableViewIndex: the UITableViewIndex is similar to the UILabel, which draw s the font and directly. Why can't setting font alone solve the problem? The size of the UITableViewIndex has been fixed since it was typeset, so setting font alone is invalid

Posted by steveh62 on Sat, 23 May 2020 08:07:25 -0700