|
@@ -12,157 +12,129 @@
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
self = [super initWithFrame:frame];
|
|
|
- CGFloat offsetx = 3.5;
|
|
|
if (self) {
|
|
|
- // Page number location
|
|
|
- _localLabel = [[UILabel alloc] init];
|
|
|
- [_localLabel setText:@"Page number position"];
|
|
|
- _localLabel.font = [UIFont boldSystemFontOfSize:12];
|
|
|
- NSArray *arraySegmmentL = [NSArray arrayWithObjects:@"Header",@"Footer", nil];
|
|
|
- _localSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentL];
|
|
|
- [self addSubview:_localLabel];
|
|
|
- [self addSubview:_localSegment];
|
|
|
- [_localLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(self.mas_top).offset(offsetx);
|
|
|
- make.left.equalTo(self.mas_left).offset(offsetx);
|
|
|
- make.width.mas_equalTo(130);
|
|
|
- make.height.mas_equalTo(22);
|
|
|
- }];
|
|
|
- [_localSegment mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_localLabel.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(self.mas_left).offset(4 * offsetx);
|
|
|
- make.width.mas_equalTo(364);
|
|
|
- make.height.mas_equalTo(44);
|
|
|
- }];
|
|
|
-
|
|
|
- // Alignment
|
|
|
- _alignmentLabel = [[UILabel alloc] init];
|
|
|
- [_alignmentLabel setText:@"alignment"];
|
|
|
- _alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
|
|
|
- NSArray *arraySegmmentA = [NSArray arrayWithObjects:@"Left",@"Center",@"Right", nil];
|
|
|
- _aligbmentSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentA];
|
|
|
- [self addSubview:_alignmentLabel];
|
|
|
- [self addSubview:_aligbmentSegment];
|
|
|
- [_alignmentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_localSegment.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(self.mas_left).offset(offsetx);
|
|
|
- make.width.mas_equalTo(100);
|
|
|
- make.height.mas_equalTo(22);
|
|
|
- }];
|
|
|
- [_aligbmentSegment mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_alignmentLabel.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(self.mas_left).offset(4 * offsetx);
|
|
|
- make.width.mas_equalTo(364);
|
|
|
- make.height.mas_equalTo(44);
|
|
|
- }];
|
|
|
-
|
|
|
- // Font color
|
|
|
- _colorLabel = [[UILabel alloc] init];
|
|
|
- [_colorLabel setText:@"Font Color"];
|
|
|
- _colorLabel.font = [UIFont boldSystemFontOfSize:12];
|
|
|
- _colerImage = [[UIImageView alloc] init];
|
|
|
- CALayer *layer = [_colerImage layer];
|
|
|
- layer.borderColor = [[UIColor blackColor] CGColor];
|
|
|
- layer.borderWidth = 0.5f;
|
|
|
- _colerImage.image = [UIImage imageNamed:@"text_color_bar"];
|
|
|
- _colorSlider = [[UISlider alloc] init];
|
|
|
- _colorSlider.minimumValue = 0;
|
|
|
- _colorSlider.maximumValue = 100;
|
|
|
- _colorSlider.value = 5;
|
|
|
- [self addSubview:_colorLabel];
|
|
|
- [self addSubview:_colorSlider];
|
|
|
- [self addSubview:_colerImage];
|
|
|
- [_colorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_aligbmentSegment.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(self.mas_left).offset(offsetx);
|
|
|
- make.width.mas_equalTo(100);
|
|
|
- make.height.mas_equalTo(22);
|
|
|
- }];
|
|
|
- [_colerImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_colorLabel.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(self.mas_left).offset(4 * offsetx);
|
|
|
- make.width.mas_equalTo(364);
|
|
|
- make.height.mas_equalTo(44);
|
|
|
- }];
|
|
|
- [_colorSlider mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_colerImage.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(self.mas_left).offset(4 * offsetx);
|
|
|
- make.width.mas_equalTo(364);
|
|
|
- make.height.mas_equalTo(44);
|
|
|
- }];
|
|
|
-
|
|
|
// Page number
|
|
|
_pageNumberLabel = [[UILabel alloc] init];
|
|
|
- [_pageNumberLabel setText:@"Page Text"];
|
|
|
- _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
|
|
|
_pageNumberText = [[UITextField alloc] init];
|
|
|
- _pageNumberText.borderStyle = UITextBorderStyleRoundedRect;
|
|
|
- _pageNumberText.placeholder = @"text";
|
|
|
+
|
|
|
[self addSubview:_pageNumberLabel];
|
|
|
[self addSubview:_pageNumberText];
|
|
|
- [_pageNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(self.mas_left).offset(offsetx);
|
|
|
- make.height.mas_equalTo(44);
|
|
|
- make.width.mas_equalTo(73);
|
|
|
- }];
|
|
|
- [_pageNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(_pageNumberLabel.mas_right).offset(offsetx);
|
|
|
- make.height.mas_equalTo(44);
|
|
|
- make.width.mas_equalTo(93);
|
|
|
- }];
|
|
|
|
|
|
// Font size
|
|
|
_fontSizeLabel = [[UILabel alloc] init];
|
|
|
- [_fontSizeLabel setText:@"Font Szie"];
|
|
|
- _fontSizeLabel.font = [UIFont boldSystemFontOfSize:14];
|
|
|
_fontSizeText = [[UITextField alloc] init];
|
|
|
- _fontSizeText.borderStyle = UITextBorderStyleRoundedRect;
|
|
|
- _fontSizeText.placeholder = @"18.0";
|
|
|
- _fontSizeText.keyboardType = UIKeyboardTypeDefault;
|
|
|
- _fontSizeText.delegate = self;
|
|
|
+
|
|
|
[self addSubview:_fontSizeLabel];
|
|
|
[self addSubview:_fontSizeText];
|
|
|
- [_fontSizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(_pageNumberText.mas_right).offset(offsetx + 20);
|
|
|
- make.height.mas_equalTo(44);
|
|
|
- make.width.mas_equalTo(73);
|
|
|
- }];
|
|
|
- [_fontSizeText mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(_fontSizeLabel.mas_right).offset(offsetx);
|
|
|
- make.height.mas_equalTo(44);
|
|
|
- make.width.mas_equalTo(93);
|
|
|
- }];
|
|
|
|
|
|
- // Font index
|
|
|
+ // Page index
|
|
|
_pageIndexLabel = [[UILabel alloc] init];
|
|
|
- [_pageIndexLabel setText:@"Page Start"];
|
|
|
- _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
|
|
|
_pageIndexNumberText = [[UITextField alloc] init];
|
|
|
- _pageIndexNumberText.borderStyle = UITextBorderStyleRoundedRect;
|
|
|
- _pageIndexNumberText.placeholder = @"1";
|
|
|
+
|
|
|
[self addSubview:_pageIndexLabel];
|
|
|
[self addSubview:_pageIndexNumberText];
|
|
|
- [_pageIndexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_pageNumberLabel.mas_bottom).offset(offsetx);
|
|
|
- make.left.equalTo(self.mas_left).offset(offsetx);
|
|
|
- make.height.mas_equalTo(44);
|
|
|
- make.width.mas_equalTo(73);
|
|
|
- }];
|
|
|
- [_pageIndexNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_pageNumberText.mas_bottom).offset(offsetx+5);
|
|
|
- make.left.equalTo(_pageIndexLabel.mas_right).offset(offsetx);
|
|
|
- make.height.mas_equalTo(33);
|
|
|
- make.width.mas_equalTo(93);
|
|
|
- }];
|
|
|
+
|
|
|
self.backgroundColor = [UIColor whiteColor];
|
|
|
}
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
+- (void)layoutSubviews {
|
|
|
+ [super layoutSubviews];
|
|
|
+ CGFloat offsetx = 3.5;
|
|
|
+
|
|
|
+ // Page number
|
|
|
+ [_pageNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
|
|
|
+ make.left.equalTo(self.mas_left).offset(offsetx);
|
|
|
+ make.height.mas_equalTo(44);
|
|
|
+ make.width.mas_equalTo(73);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [_pageNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
|
|
|
+ make.left.equalTo(_pageNumberLabel.mas_right).offset(offsetx);
|
|
|
+ make.height.mas_equalTo(44);
|
|
|
+ make.width.mas_equalTo(93);
|
|
|
+ }];
|
|
|
+
|
|
|
+ // Font size
|
|
|
+ [_fontSizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
|
|
|
+ make.left.equalTo(_pageNumberText.mas_right).offset(offsetx + 20);
|
|
|
+ make.height.mas_equalTo(44);
|
|
|
+ make.width.mas_equalTo(73);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [_fontSizeText mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
|
|
|
+ make.left.equalTo(_fontSizeLabel.mas_right).offset(offsetx);
|
|
|
+ make.height.mas_equalTo(44);
|
|
|
+ make.width.mas_equalTo(93);
|
|
|
+ }];
|
|
|
+
|
|
|
+ // Page index
|
|
|
+ [_pageIndexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(_pageNumberLabel.mas_bottom).offset(offsetx);
|
|
|
+ make.left.equalTo(self.mas_left).offset(offsetx);
|
|
|
+ make.height.mas_equalTo(44);
|
|
|
+ make.width.mas_equalTo(73);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [_pageIndexNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(_pageNumberText.mas_bottom).offset(offsetx+5);
|
|
|
+ make.left.equalTo(_pageIndexLabel.mas_right).offset(offsetx);
|
|
|
+ make.height.mas_equalTo(33);
|
|
|
+ make.width.mas_equalTo(93);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setText {
|
|
|
+ // Page number location
|
|
|
+ [self.localLabel setText:@"Page number position"];
|
|
|
+ self.localLabel.font = [UIFont boldSystemFontOfSize:12];
|
|
|
+
|
|
|
+ // Alignment
|
|
|
+ [self.alignmentLabel setText:@"alignment"];
|
|
|
+ self.alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
|
|
|
+
|
|
|
+ // Font color
|
|
|
+ [self.colorLabel setText:@"Font Color"];
|
|
|
+ self.colorLabel.font = [UIFont boldSystemFontOfSize:12];
|
|
|
+
|
|
|
+ CALayer *layer = [self.colerImage layer];
|
|
|
+ layer.borderColor = [[UIColor blackColor] CGColor];
|
|
|
+ layer.borderWidth = 0.5f;
|
|
|
+ self.colerImage.image = [UIImage imageNamed:@"text_color_bar"];
|
|
|
+
|
|
|
+ self.colorSlider.minimumValue = 0;
|
|
|
+ self.colorSlider.maximumValue = 100;
|
|
|
+ self.colorSlider.value = 5;
|
|
|
+
|
|
|
+ // Page number
|
|
|
+ [_pageNumberLabel setText:@"Page Text"];
|
|
|
+ _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
|
|
|
+
|
|
|
+ _pageNumberText.borderStyle = UITextBorderStyleRoundedRect;
|
|
|
+ _pageNumberText.placeholder = @"text";
|
|
|
+
|
|
|
+ // Font size
|
|
|
+ [_fontSizeLabel setText:@"Font Szie"];
|
|
|
+ _fontSizeLabel.font = [UIFont boldSystemFontOfSize:14];
|
|
|
+
|
|
|
+ _fontSizeText.borderStyle = UITextBorderStyleRoundedRect;
|
|
|
+ _fontSizeText.placeholder = @"18.0";
|
|
|
+ _fontSizeText.delegate = self;
|
|
|
+ _fontSizeText.keyboardType = UIKeyboardTypeDefault;
|
|
|
+
|
|
|
+ // Page index
|
|
|
+ [_pageIndexLabel setText:@"Page Start"];
|
|
|
+ _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
|
|
|
+
|
|
|
+ _pageIndexNumberText.borderStyle = UITextBorderStyleRoundedRect;
|
|
|
+ _pageIndexNumberText.placeholder = @"1";
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - UITextFieldDelegate
|
|
|
|
|
|
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|