小编and*_*ius的帖子

如何替换(n?)UIButton的现有动作?

到目前为止,我一直在使用

[button1 addTarget:self action:@selector(newAction) forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)

这增加了一个额外的动作(我认为).如何用新的操作替换初始操作?

iphone uibutton

7
推荐指数
1
解决办法
1947
查看次数

我如何(成功)将maskView设置为UIView?

我正在制作一个基于相机的应用程序,并希望在相机预览上制作一个磨砂覆盖图,从磨砂视图中切出一个圆角矩形.

我一直在努力用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)

mask objective-c uiview ios ios8

5
推荐指数
1
解决办法
6670
查看次数

如何在不举起其他内容的情况下下载图像?

我正在制作一个应用程序,允许您浏览网站上的图片.我目前正在使用以下方式下载图像:

 UIImage *myImage = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
Run Code Online (Sandbox Code Playgroud)

这很好用,但可能很耗时.我开始下载20张图片,但是直到30秒左右下载所有图片之后我才能做任何事情.

这一次等待并不是那么糟糕,但如果我想下载第二十四张图像,我将不得不再等30秒.

基本上,有没有一种方法可以一次下载这些图像而不需要保留任何动画?

谢谢.

iphone objective-c uiimage

2
推荐指数
1
解决办法
1095
查看次数

标签 统计

iphone ×2

objective-c ×2

ios ×1

ios8 ×1

mask ×1

uibutton ×1

uiimage ×1

uiview ×1