2

Estoy realizando un código a través del cual cambio de lugar una imagen y a la vez se modifica el tamaño de la misma utilizando CGSizeMake, pero no logro modificar las dimensiones solo desplazarlo,

import UIKit
import QuartzCore

class ViewController: UIViewController {

    @IBOutlet weak var imagen: UIImageView!

    @IBAction func animar(sender: AnyObject) {

        var animation = CABasicAnimation(keyPath: "position")
        animation.fromValue = NSValue(CGPoint: CGPointMake(self.imagen.frame.midX, self.imagen.frame.midY))
        animation.toValue = NSValue(CGPoint: CGPointMake(160, 200))
        animation.duration = 3.0

        **var resizeAnimation = CABasicAnimation(keyPath: "bound.size")
        resizeAnimation.fromValue = NSValue(CGSize: self.imagen.bounds.size)
        resizeAnimation.toValue = NSValue(CGSize: CGSizeMake(200, 50))
        resizeAnimation.duration = 3.0**

        imagen.layer.addAnimation(animation, forKey: "position")
        imagen.layer.addAnimation(resizeAnimation, forKey: "bound.size")    
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }    
}

no encuentro el error,

gracias por la ayuda

1 respuesta 1

2

Te has olvidado una s en CABasicAnimation(keyPath: "bound.size") Es decir, lo correcto es:

CABasicAnimation(keyPath: "bounds.size")
2
  • Muchas Gracias! ese efectivamente ese fue el error, lo pase por alto.
    – Luis
    el 21 feb. 2016 a las 14:17
  • Hola +Luis. ¿No deberías también acepar la la respuesta como correcta? saludos el 6 ago. 2016 a las 2:10

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.