Gestures day1

#brunomacabeusbr

#felipe

@bepid

Gesture é o uso de um determinado gesto com os dedos na tela para ativar uma determinação ação

Gestures?

Exemplos de aplicativos

Paper by FiftyThree

Exemplos de aplicativos

Tider

Código

Criando gestures

@IBAction func gstTap(sender: UITapGestureRecognizer) {
  if let view = sender.view {
      // fazer algo com view
  }
}
@IBAction func gstPan(sender: UIPanGestureRecognizer) {
  let translation = sender.translationInView(self.view) // pegar translação
        
  if let view = sender.view {
    // fazer algo com view e translation
  }
        
  sender.setTranslation(CGPointZero, inView: self.view) // precise recomeçar a contagem
}
@IBAction func gstPinch(sender: UIPinchGestureRecognizer) {
  if let view = sender.view {
    // fazer algo com view usando o sender.scale
    sender.scale = 1 // necessário para não entrar novamente aqui
  }
}

Pinch

Pan

Tap

discrete gestures 

    continuous gestures

    continuous gestures

discrete gestures 

Hands on

Temos várias gestures.

Que tal explorá-las,

e fazer alguma coisa com elas?

Layout

Pensamento

I like to approach gestures as supporting actions that can accomplish tasks quicker than any other action (e.g. a click, a button, etc.). When it comes to selecting, think of it this way: Does the action the person is completing in their experience directly correspond to an action on the screen? If so, a gesture might be a good alternative to a traditional action.

- Andrew Rudmann, Director of Product at Tinder

Mais versáteis

 

Mais delightful

 

Mais economia de espaço

Layout

vantagens x desvantagens

Ficam escondidas

 

Falta de um padrão

Para resolver os problemas, podemos buscar padrões e ensinar nossos usuários

Layout

Resolvendo problemas

Hands on

Nós fizemos excelentes apps.

 

Que tal explorá-los?

E ver onde poderíamos melhorar com gestures?

Código

States

enum UIGestureRecognizerState : Int {
    case Possible
    case Began
    case Changed
    case Ended
    case Cancelled
    case Failed
    static var Recognized: UIGestureRecognizerState { get }
}

Usado para saber em que momento está o gesto (se está começando, terminando, etc)

var sum = 0
var total = 0

@IBAction func gstPan(sender: UIPanGestureRecognizer) {
  let translation = recognizer.translationInView(self.view)
  print(translation)
  recognizer.setTranslation(CGPointZero, inView: self.view)

  self.sumX += translation.x
  total += 1

  if recognizer.state == UIGestureRecognizerState.Ended {
    print(self.sumX / total)
    self.sumX = 0
    self.total = 0
  }
}

É possível obter excelentes efeitos usando Gestures com UIDynamics

Código

Gestures + UIDynamics

todo: por uma animação e código usando Gestures

com UIDynamics

Hands on

todo: pensar numa hands on envolvendo gesture + uidynamics

http://babich.biz/in-app-gestures-and-mobile-app-usability/

 

http://tableless.com.br/design-para-telas-sensiveis-ao-toque/

 

http://www.apptentive.com/blog/in-app-gestures-an-interview-with-tinder/

 

http://blog.maxrudberg.com/post/38958984259/if-you-see-a-ui-walkthrough-they-blew-it

 

https://www.raywenderlich.com/76020/using-uigesturerecognizer-with-swift-tutorial

Bibliografia

gestures-day1

By brunomacabeus

gestures-day1

  • 617