123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //
- // PDFKTFontNameView.m
- // PDFReader
- //
- // Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
- //
- // The PDF Reader Sample applications are licensed with a modified BSD license.
- // Please see License for details. This notice may not be removed from this file.
- //
- #import "PDFKTFontNameView.h"
- @implementation PDFKTFontNameView
- {
- UITableView *_fontNamesTableView;
- }
- @synthesize fontNamedelegate = _fontNamedelegate;
- @synthesize fontNames = _fontNames;
- - (id)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
-
- _fontNamesTableView = [[UITableView alloc] initWithFrame:self.bounds];
- _fontNamesTableView.delegate = self;
- _fontNamesTableView.dataSource = self;
- _fontNamesTableView.separatorInset = UIEdgeInsetsZero;
- _fontNamesTableView.backgroundColor = [UIColor clearColor];
- _fontNamesTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
- [self addSubview:_fontNamesTableView];
-
- _fontNames = [[NSArray alloc] initWithObjects:@"Helvetica", @"Courier", @"Times-Roman",nil];
- }
- return self;
- }
- - (void)dealloc
- {
- _fontNamedelegate = nil;
- _fontNamesTableView.delegate = nil;
- _fontNamesTableView.dataSource = nil;
- [_fontNamesTableView release];
- [_fontNames release];
- [_fontName release];
- [super dealloc];
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- self.fontName = self.fontNames[indexPath.row];
- [_fontNamesTableView reloadData];
- if ([_fontNamedelegate respondsToSelector:@selector(fontNamesView:didSelectedTextFontName:)]) {
- [_fontNamedelegate fontNamesView:self didSelectedTextFontName:[_fontNames objectAtIndex:indexPath.row]];
- }
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return [_fontNames count];
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 40;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"FontNameCell";
-
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
- }
- NSString *fontName = [_fontNames objectAtIndex:indexPath.row];;
-
- cell.textLabel.text = fontName;
- [cell.textLabel setFont:[UIFont fontWithName:fontName size:18]];
- cell.backgroundColor = [UIColor clearColor];
-
- if ([self.fontName isEqualToString:fontName]) {
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- } else {
- cell.accessoryType = UITableViewCellAccessoryNone;
- }
- cell.backgroundColor = [UIColor clearColor];
-
- return cell;
- }
- @end
|