Skip to content

Commit c54cea9

Browse files
committed
-调整示例代码,横屏使用UIView布局的水印
1 parent b6b3d27 commit c54cea9

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

LFCameraPickerControllerDEMO/LFCameraPickerControllerDEMO/ViewController.m

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,17 @@ - (UIView *)lf_cameraPickerController:(LFCameraPickerController *)picker overlay
123123

124124
CGSize size = CGSizeMake(height, width);
125125

126-
// 并把它设置成为当前正在使用的context
127-
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
128-
[[UIColor clearColor] setFill];
129-
[@"哈哈哈哈,测试用" drawInRect:CGRectMake(0, 0, 200, 100) withAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17.f], NSForegroundColorAttributeName:[UIColor redColor]}];
130126

131-
// 从当前context中创建一个改变大小后的图片
132-
UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
127+
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
128+
label.textColor = [UIColor redColor];
129+
label.font = [UIFont systemFontOfSize:17.f];
130+
label.text = @"哈哈哈哈,测试用";
131+
[label sizeToFit];
133132

134-
// 使当前的context出堆栈
135-
UIGraphicsEndImageContext();
136-
137-
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
138-
[imageView setImage:image];
139-
imageView.contentMode = UIViewContentModeScaleAspectFit;
133+
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
134+
[view addSubview:label];
140135

141-
return imageView;
136+
return view;
142137
}
143138
break;
144139
}

0 commit comments

Comments
 (0)