gpt4 book ai didi

ios - UIImagePickerController 添加文本到图像

转载 作者:行者123 更新时间:2023-12-03 16:46:20 25 4
gpt4 key购买 nike

我正在尝试使用 iOS 中的相机捕获图像或视频,并向覆盖在图像底部的黑条添加一些文本。

我正在尝试从用户输入中获取文本,并将图像与图像底部的文本和矩形一起保存:

enter image description here

我该如何解决这个问题?

我目前有这个:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
// A photo was taken/selected!
self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Save the image!
UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
}
}
else {
// A video was taken/selected!
self.videoFilePath = (__bridge NSString *)([[info objectForKey:UIImagePickerControllerMediaURL] path]);
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {

// Save the video!
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.videoFilePath)) {
UISaveVideoAtPathToSavedPhotosAlbum(self.videoFilePath, nil, nil, nil);
}
}
}

[self dismissViewControllerAnimated:YES completion:nil]; }

解决这个问题的最佳方法是什么?

最佳答案

您可以在具有黑色(alpha 为 0.5)背景的 UIImageView 上添加 UIView,并在此 UIView 上添加带有文本的 UILabel。

关于ios - UIImagePickerController 添加文本到图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21187042/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com