标签: uiviewanimation

UIView动画问题,当尝试没有动画图像时

我必须显示图像的幻灯片.但有一刻我只知道当前和以前的图像(因为内存管理).我需要用动画显示下一个图像(用户可以显示动画类型).但我看不到动画,只是出现没有动画的新图像.这是我的代码:

    UIImageView *prevImageView = [self getImageViewWithIndex:currentIndex];
    UIImageView *nowImageView = [self getImageViewWithIndex:newIndex];

    currentIndex = newIndex;
    [UIView animateWithDuration:4 delay:0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
        [slideShowView addSubview:nowImageView];
    } completion:^(BOOL finished) {
        [prevImageView removeFromSuperview];
    }];
Run Code Online (Sandbox Code Playgroud)

我尝试了不同的动画选项.试图将新图像设置为现有图像视图

nowImageView.image = newImage;
Run Code Online (Sandbox Code Playgroud)

但这没有帮助.

iphone core-animation uiimageview uiviewanimation ios

0
推荐指数
1
解决办法
1104
查看次数

UIButton没有处理动画子视图

我想在显示视图时向父视图上显示的子视图添加两个按钮.按钮被正确初始化并显示,但按下时它们没有反应.有人知道为什么吗?这是我的代码:

-(void) viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];
    self.view.backgroundColor = [UIColor blackColor];
    //Animation View
    imageView= [[UIImageView alloc] initWithFrame:CGRectMake(0, 499, 320, 0)];
    imageView.image = [UIImage imageNamed:@"trans.png"];
    [imageView setClipsToBounds:YES];
    [imageView setContentMode:UIViewContentModeBottom];
    [self.view addSubview:imageView];


    [UIView animateWithDuration:1.0f
                          delay:0.5f
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^(void) {
                         imageView.frame = CGRectMake(0, 92, 320, 320);

                     }
                     completion:NULL];
    [self.view bringSubviewToFront:imageView];
    // Animation View Buttons
    //1 Amazon
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage *button=[UIImage imageNamed:@"button.png"];
    [button1 setImage:button forState:UIControlStateNormal];
    button1.frame = CGRectMake(0, 290, 80, 30);
    button1.backgroundColor=[UIColor whiteColor];
    button1.showsTouchWhenHighlighted=YES;

    [button1 addTarget:self
                action:@selector(openAmazon:)
     forControlEvents:UIControlEventTouchUpInside];
    [imageView addSubview:button1];

    //2 iTunes
    UIButton *button2 …
Run Code Online (Sandbox Code Playgroud)

objective-c uibutton uiviewanimation

0
推荐指数
1
解决办法
1103
查看次数

弹出不在设备中工作的视图

我通过放大缩小效果显示弹出视图.当我的应用程序将在登录后从safari返回我正在显示该视图.这在模拟器中工作正常.但它不适用于设备.我在ipad检查那件事.这是我的代码:

    [MyAppDelegate openSessionWithAllowLoginUI:YES completionBlock:^(BOOL result) {
    NSLog(@"Connecte via Joint Page Thank you");
    if (result) {
        NSLog(@"%@  %d ", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation],[[[NSUserDefaults standardUserDefaults] valueForKey:@"isSender"]boolValue]);
        if([[[NSUserDefaults standardUserDefaults] valueForKey:@"isSender"]boolValue]==0 && [[[NSUserDefaults standardUserDefaults] valueForKey:@"isServiceProvider"] boolValue]==0){
            lbl_register.font=[UIFont fontWithName:GZFont size:16];
            lbl_serviceProvider.font=[UIFont fontWithName:GZFont size:14];
            lbl_customer.font=[UIFont fontWithName:GZFont size:14];
        SelectionView.center=self.view.center;
            SelectionView.layer.borderColor=[[UIColor blackColor] CGColor];
            SelectionView.layer.borderWidth=1.0;
            SelectionView.layer.cornerRadius=5;
            SelectionView.layer.masksToBounds=YES;

            [UIView animateWithDuration:0.4 animations:^{
                SelectionView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
            } completion:^(BOOL finished) {
                NSLog(@"popped");
                SelectionView.center=self.view.center;

                [UIView animateWithDuration:0.4 animations:^{
                    SelectionView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.95,0.95);
                } completion:^(BOOL finished) {
                   // self.view.userInteractionEnabled=NO;
                }];
            }];
            [self.view addSubview:SelectionView];
Run Code Online (Sandbox Code Playgroud)

iphone uiviewanimation ios ios7

0
推荐指数
1
解决办法
81
查看次数

动画中的 UIView 幻灯片

我在 UIView 中有一个文本字段,我想在用户访问该 VC 时将其滑入。这容易实现吗?如果是这样,我该怎么做?

uiviewanimation ios swift

0
推荐指数
1
解决办法
6754
查看次数

使用 CAKeyframeAnimation 延迟 UIView 的动画开始?

以下代码是从另一个 SO 答案中提取的,但是是否可以延迟该CAKeyframeAnimation动画的开始,类似于 UIViewanimateWithDuration提供delay属性的方式?

根据类文档,该类CAKeyframeAnimation似乎不包含延迟属性。

    let animation = CAKeyframeAnimation(keyPath: "transform.translation.x")
    animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
    animation.duration = 1.0
    animation.repeatCount = 2
    animation.values = [-10, 10, -10, 10, -5, 5, -2, 2, 0]
    view.layer.addAnimation(animation, forKey: "shake")
Run Code Online (Sandbox Code Playgroud)

core-animation uiview cakeyframeanimation uiviewanimation ios

0
推荐指数
1
解决办法
1688
查看次数

推送时未调用 animateTransition

我刚刚指出:

func animateTransition(transitionContext: UIViewControllerContextTransitioning)
Run Code Online (Sandbox Code Playgroud)

不叫 id 我推我的UIViewController

navigationController?.pushViewController(nextVC, animated: true)
Run Code Online (Sandbox Code Playgroud)

否则,如果我展示我的UIViewController

navigationController?.presentViewController(nextVC, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我的动画有效是因为 animateTransition 被调用

编辑:

它的用法如下:

let transitionManager = TransitionManager()
nextVC.transitioningDelegate = transitionManager
navigationController?.pushViewController(nextVC, animated: true)
Run Code Online (Sandbox Code Playgroud)

完整的动画类是:

class TransitionManager: NSObject, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate {
    private var presenting = true

    func animateTransition(transitionContext: UIViewControllerContextTransitioning) {

        let container = transitionContext.containerView()
        let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey)!
        let toView = transitionContext.viewForKey(UITransitionContextToViewKey)!


        let offScreenRight = CGAffineTransformMakeTranslation(container!.frame.width, 0)
        let offScreenLeft = CGAffineTransformMakeTranslation(-container!.frame.width, 0)

        toView.transform = offScreenRight

        container!.addSubview(toView)
        container!.addSubview(fromView)


        let duration …
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller uiviewanimation ios swift

0
推荐指数
1
解决办法
2727
查看次数

如何用动画更改导航栏的背景图片?

我正在使用我们所有人的已知动画,动画更改导航栏的背景图像,延迟时间将其从半透明(我将其设为默认值)更改为(蓝色主题).

UIView.animate(withDuration:0.5, 
               delay: 0, 
               option: UIViewAnimationOptions.curveEaseOut, 
               animations: {
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
        self.navigationController?.navigationBar.shadowImage = UIImage()
    }, completion: nil)
Run Code Online (Sandbox Code Playgroud)

但动画没有用,但导航栏的背景图像改变成功,我不知道为什么!!

有任何想法吗?

uinavigationbar uiviewanimation ios swift3

0
推荐指数
1
解决办法
1194
查看次数

UITableViewCell 内的 UIButton 默认点击动画

UIButtons我里面有一些UITableViewCells,并且所有这些都缺少默认的点击动画,但是如果我长按 - 动画就会起作用。我找到了一些解决方案,例如将 type 设置为.system, showsTouchOnHighlight = true,但没有一个有帮助。这里有什么问题?

uibutton uitableview uiviewanimation ios swift

0
推荐指数
1
解决办法
774
查看次数

swiftUI如何制作气泡效果?

尝试了几种方法让它的气泡效果从下到上移动。

我能够将其从底部移动到顶部。但我无法做出像气泡一样的效果。

@State private var bouncing = true
var body: some View {
    Image("bubble").resizable()
        .aspectRatio(contentMode: .fit)
        .frame(height: 40)
        .frame(maxHeight: .infinity, alignment: bouncing ? .bottom : .top)
        .animation(Animation.easeInOut(duration: 5.0).repeatForever(autoreverses: false))
        .onAppear {
            self.bouncing.toggle()
        }
    
}
Run Code Online (Sandbox Code Playgroud)

这是我正在寻找的简单气泡动画。在此输入图像描述

core-animation uiviewanimation swiftui

0
推荐指数
1
解决办法
1519
查看次数

旋转拨号器就像动画一样

我正在使用MHRotaryKnob来制作像动画一样的旋转拨号.我用它来制作旧的电话拨号盘.
图像.
目前它只是显示动画,当我拨打它刚刚回来的动画片.即使第一个圆圈从较低甚至没有检测到触摸,触摸也在那里工作,没有圆圈拨号.下面我发布我正在使用的代码.

 - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
 {
CGPoint point = [touch locationInView:self];

if (self.interactionStyle == MHRotaryKnobInteractionStyleRotating)
{
    // If the touch is too close to the center, we can't calculate a decent
    // angle and the knob becomes too jumpy.
    if ([self squaredDistanceToCenter:point] < MinDistanceSquared)
        return NO;

    // Calculate starting angle between touch and center of control.
    _angle = [self angleBetweenCenterAndPoint:point];
}
else
{
    _touchOrigin = point;
    _angle = [self angleForValue:self.value];
}

self.highlighted = YES;
[self showHighlighedKnobImage]; …
Run Code Online (Sandbox Code Playgroud)

iphone uiviewanimation ios

-1
推荐指数
1
解决办法
645
查看次数

动画集合视图单元格

如何为集合视图单元设置动画,例如iOS中左右门的关闭或滑动。像这样:在此处输入图片说明

uikit uiviewanimation uicollectionview uicollectionviewcell swift

-1
推荐指数
1
解决办法
2504
查看次数