到目前为止,我一直在使用
[button1 addTarget:self action:@selector(newAction) forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)
这增加了一个额外的动作(我认为).如何用新的操作替换初始操作?
我正在制作一个基于相机的应用程序,并希望在相机预览上制作一个磨砂覆盖图,从磨砂视图中切出一个圆角矩形.
我一直在努力用UIView的maskLayer实现这一点,在iOS 8中引入并且已经非常不成功.
这是我的代码目前的样子:
// Blur the preview
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIView *blurView = [[UIVisualEffectView alloc] initWithEffect:effect];
blurView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view insertSubview:blurView aboveSubview:imagePicker.view];
// Make blur view fill screen
{
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[blurView]-0-|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(blurView)]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[blurView]-0-|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(blurView)]];
}
// Add a rounded of transparency to the blurView **not working**
UIView *mask = [[UIView alloc] initWithFrame:CGRectMake(50.f, 50.f, 50.f, 50.f)];
mask.alpha = 1.0f;
mask.backgroundColor = [UIColor redColor];
[blurView setMaskView:mask]; // Remove this line, and everything …Run Code Online (Sandbox Code Playgroud) 我正在制作一个应用程序,允许您浏览网站上的图片.我目前正在使用以下方式下载图像:
UIImage *myImage = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
Run Code Online (Sandbox Code Playgroud)
这很好用,但可能很耗时.我开始下载20张图片,但是直到30秒左右下载所有图片之后我才能做任何事情.
这一次等待并不是那么糟糕,但如果我想下载第二十四张图像,我将不得不再等30秒.
基本上,有没有一种方法可以一次下载这些图像而不需要保留任何动画?
谢谢.