【问题标题】:Want to get animation like opening a camera shutter in iphone想要获得像在 iphone 中打开相机快门一样的动画
【发布时间】:2013-03-30 07:48:58
【问题描述】:

我正在根据要求制作基于摄影的应用程序,我必须在菜单中显示所有进度或活动指示器,以使其看起来像打开相机快门。

为了更好的解释,请参阅附图。

如图所示,加载时关闭的相机快门应该会旋转,加载后应该会在打开相机快门后出现。

请告诉我如何实现这种动画..

编辑:我从This Question 得到了一个代码。我用过这样的代码

-(void)shutter
{
    CATransition *shutterAnimation = [CATransition animation];
    [shutterAnimation setDelegate:self];
    [shutterAnimation setDuration:1.5];
    shutterAnimation.timingFunction = UIViewAnimationCurveEaseInOut;
    [shutterAnimation setType:@"cameraIris"];
    [shutterAnimation setValue:@"cameraIris" forKey:@"cameraIris"];
    [shutterAnimation setRepeatDuration:4.5];
    [[[self.view viewWithTag:90] layer] addAnimation:shutterAnimation forKey:@"cameraIris"];

}

但它给了我方形动画,我想要这个圆形动画。见附图。

我试着给这个层像这样的圆角半径

[[[self.view viewWithTag:90] layer] setCornerRadius:75.0];//size of this view is 150X150 so i give radius 75 to make it round.
[[[self.view viewWithTag:90] layer] setBorderWidth:2.0];
[[[self.view viewWithTag:90] layer] setBorderColor:[[UIColor blackColor] CGColor]];

但是这段代码不起作用.... 请指导我如何制作圆形动画。

【问题讨论】:

    标签: ios uiimageview uiviewanimation uiactivityindicatorview caanimation


    【解决方案1】:

    让你的 SQUARE UIImageView 变成圆形:

    CALayer *imageViewLayer = [imageView layer];
    [imageViewLayer setMasksToBounds:YES];
    [imageViewLayer setCornerRadius:imageView.frame.size.height/2];
    

    【讨论】:

    • 请告诉我如何更改快门的颜色。默认为深灰色
    • 我不知道.. 不要认为这是可能的。如果您真的需要“颜色”,您可以在快门上方添加一个 UIView。然后,例如将 UIView 背景颜色设置为 RED,并调整 UIView 的 alpha 值,以便在快门上获得红色调。 :)
    • 感谢您的快速回复。我试过这里是我的代码。 [vv setBackgroundColor:[UIColor redColor]]; [vv setAlpha:1.0]; [[self.view viewWithTag:90] addSubview:vv]; 但它不起作用 –
    • 什么不起作用?试试这个:CGRect frame = CGRectMake(yourShutterX, yourShutterY, yourShutterW, yourShutterH); UIView *subView = [[UIView alloc] initWithFrame:frame]; subView.backgroundColor = [UIColor redColor]; sebView.setAlpha = 0.5; [self.view addSubview:subView];
    猜你喜欢
    • 2011-03-09
    • 2013-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-15
    相关资源
    最近更新 更多