1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // CPDFAnnotationBaseViewController.m
- // compdfkit-tools
- //
- // Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
- //
- // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
- // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
- // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
- // This notice may not be removed from this file.
- //
- #import "CPDFAnnotationBaseViewController.h"
- #import "CPDFAnnotationBaseViewController_Header.h"
- @interface CPDFAnnotationBaseViewController () <CPDFColorSelectViewDelegate>
- @property (nonatomic, strong) CAnnotStyle *annotStyle;
- @end
- @implementation CPDFAnnotationBaseViewController
- #pragma mark - Initializers
- - (instancetype)initWithStyle:(CAnnotStyle *)annotStyle {
- if (self = [super init]) {
- self.annotStyle = annotStyle;
- }
- return self;
- }
- #pragma mark - ViewController Methods
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.titleLabel = [[UILabel alloc] init];
- self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
- self.titleLabel.font = [UIFont systemFontOfSize:20];
- self.titleLabel.adjustsFontSizeToFitWidth = YES;
- [self.view addSubview:self.titleLabel];
-
- self.sampleView = [[CPDFAnnotationSampleView alloc] init];
- self.sampleView.backgroundColor = [UIColor whiteColor];
- self.sampleView.layer.borderColor = [UIColor purpleColor].CGColor;
- self.sampleView.layer.borderWidth = 1.0;
- self.sampleView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
- [self.view addSubview:self.sampleView];
-
- self.colorView = [[CPDFColorSelectView alloc] initWithFrame:CGRectMake(0, 190, self.view.frame.size.width, 90)];
- self.colorView.delegate = self;
- self.colorView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- [self.view addSubview:self.colorView];
-
- self.opacitySliderView = [[CPDFOpacitySliderView alloc] init];
- self.opacitySliderView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- [self.view addSubview:self.opacitySliderView];
-
- self.view.backgroundColor = [UIColor whiteColor];
- [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
-
- [self commomInitTitle];
- }
- - (void)viewWillLayoutSubviews {
- self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, 50);
- self.sampleView.frame = CGRectMake((self.view.frame.size.width - 300)/2, 60, 300, 120);
- self.opacitySliderView.frame = CGRectMake(0, 280, self.view.frame.size.width, 90);
- self.colorPicker.frame = self.view.frame;
- }
- - (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
- [super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
- [self updatePreferredContentSizeWithTraitCollection:newCollection];
- }
- - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection
- {
- self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 270 : 420);
- }
- #pragma mark - Protect Methods
- - (void)commomInitTitle {
- self.titleLabel.text = NSLocalizedString(@"Note", nil);
- }
- #pragma mark - CPDFColorSelectViewDelegate
- - (void)colorSelect:(CPDFColorSelectView *)select {
- _colorPicker = [[CPDFColorPickerView alloc] initWithFrame:self.view.frame];
- _colorView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- _colorPicker.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:self.colorPicker];
- }
- @end
|