"double"类型的集合元素不是Objective-C对象

spr*_*gbo 7 objective-c nsnumber

inY属性给出了错误.什么是正确的语法?

UIButton *optionButton = [UIButton buttonWithType:UIButtonTypeCustom];
NSObject* anim = @{@"target": target, @"inY": infoView.frame.size.height-100, @"outY": @800};
Run Code Online (Sandbox Code Playgroud)

尝试使用它创建一个变量,optionButton但它似乎不起作用.我认为我需要把它作为集合可以理解的东西.

Wai*_*ain 12

infoView.frame.size.height-100是一个浮动.你无法施放它,你需要将它包装成一个NSNumber(类似于你对它的800值所做的outY):

@(infoView.frame.size.height-100)
Run Code Online (Sandbox Code Playgroud)