【发布时间】:2015-04-28 16:54:48
【问题描述】:
我要截取ViewController的截图,模糊图像,发送到ProfileViewController,然后设置为ProfileViewController的背景>。这应该不是那么困难,因为每项任务都非常简单,我只是很难找到正确的语法来说明如何执行此操作。
我希望它的工作方式是这样的:
- 用户从主视图 ViewController 开始。
- 单击按钮(标记为 profTap)后,用户将转到 ProfileViewController。
- ProfileViewController 通过 segue(模态呈现)显示,其背景设置为来自 ViewController 的前一个视图的模糊图像。
如果有人可以向我展示如何将图像发送到 ProfileViewController 的代码,我将不胜感激。作为参考,下面是我的 ViewController 代码。我相信我正确捕获了图像,但我不确定从这里如何将其发送到 ProfileViewController.
#import "ViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "ProfileViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)profTap:(id)sender {
UIGraphicsBeginImageContext(self.mainView.bounds.size);
[self.mainView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *mainViewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data = UIImagePNGRepresentation(mainViewImage);
// NEXT: blur image, and send to ProfileViewControoler
// UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mainViewImage"]];
// [self.view addSubview:backgroundView];
}
- (IBAction)unwindToHome:(UIStoryboardSegue *)segue {
}
@end
【问题讨论】:
-
您在问两个不同的问题。如何模糊以及如何将最终图像发送到新控制器。每个帖子只问一个问题。
-
好吧,我实际上是在问四个问题:如何截屏、模糊、发送和设置为背景。我想我真正的问题是如何将“模糊图像”发送到另一个控制器。我想我会编辑我的帖子
标签: ios objective-c oop uiviewcontroller