123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //
- // PDFSettingFontView.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 "PDFSettingFontView.h"
- @interface PDFSettingFontView ()
- @property (nonatomic, assign) NSInteger minValue;
- @property (nonatomic, assign) NSInteger maxValue;
- @property (nonatomic, retain) UITableView *tableView;
- @end
- @implementation PDFSettingFontView
- - (id)initWithFrame:(CGRect)frame
- minValue:(NSInteger)minValue
- maxValue:(NSInteger)maxValue{
- self = [super initWithFrame:frame];
- self.minValue = minValue;
- self.maxValue = maxValue;
- if (self) {
- _tableView = [[UITableView alloc] initWithFrame:self.bounds];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.separatorInset = UIEdgeInsetsZero;
- _tableView.backgroundColor = [UIColor clearColor];
- _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
- [self addSubview:_tableView];
- }
- return self;
- }
- - (void)dealloc
- {
- _fontNamedelegate = nil;
- _tableView.delegate = nil;
- _tableView.dataSource = nil;
- [_tableView release];
-
- [super dealloc];
- }
- - (void)setCurValue:(NSInteger)curValue
- {
- _curValue = curValue;
- [_tableView reloadData];
- NSInteger row = self.curValue - self.minValue;
- NSIndexPath * indexPath = [NSIndexPath indexPathForRow:row inSection:0];
- [_tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- self.curValue = _minValue + indexPath.row;
- if ([_fontNamedelegate respondsToSelector:@selector(fontNamesView:didSelectedTextFontName:)]) {
- [_fontNamedelegate fontNamesView:self didSelectedTextsize:(_minValue + indexPath.row)];
- }
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return _maxValue - _minValue + 1;
- }
- - (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];
- cell.backgroundColor = [UIColor clearColor];
- }
-
- cell.textLabel.text = [NSString stringWithFormat:@"%@",@(_minValue + indexPath.row)];
-
- if (self.curValue == _minValue + indexPath.row) {
- cell.accessoryType = UITableViewCellAccessoryCheckmark;
- } else {
- cell.accessoryType = UITableViewCellAccessoryNone;
- }
-
- cell.backgroundColor = [UIColor clearColor];
- return cell;
- }
- @end
|