Nil is not compatible with expected argument type UIViewAnimationOptions

前端 未结 3 583
南笙
南笙 2021-02-01 13:32

I just started programming and following a tutorial online I was unable to create this animation. Can anyone tell me why it\'s saying:

Nil is not compati

相关标签:
3条回答
  • 2021-02-01 13:41

    UIViewAnimationOptions is an enum backed by integers. You should pass 0. Here is the doc for the enum.

    0 讨论(0)
  • 2021-02-01 13:45

    You may replace options: nil with options: [] should make the error goes way.

    Good luck !

    0 讨论(0)
  • 2021-02-01 13:58

    It's because UIViewAnimationOptions is an OptionSet type, not Optional type OptionSet according to apple

    You use the OptionSet protocol to represent bitset types, where individual bits represent members of a set.

    it's mainly used to create a combined flag from the current flags inside the set, in your case animation flags or types we can call them, this will give you the ability to combine options to make the final desired option, there are about 23 option, however in your case you can just pass an empty OptionSet as []

    0 讨论(0)
提交回复
热议问题