我想知道如何以编程方式将imageview编码为全屏。现在,我知道如何以编程方式将对象编码为特定的大小和位置,但是无论如何使用哪种设备,我都想知道如何以全屏方式显示该对象。
FIRE.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
FIRE.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
FIRE.widthAnchor.constraint(equalToConstant: 400).isActive = true
FIRE.heightAnchor.constraint(equalToConstant: 700).isActive = true
FIRE.translatesAutoresizingMaskIntoConstraints = false
答案 0 :(得分:1)
我假设您的对象是json_encode($array_name);
,父视图是FIRE
。您可以按以下约束进行操作。
view
或者您可以使用自动调整大小的蒙版
FIRE.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
FIRE.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
FIRE.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
FIRE.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
FIRE.translatesAutoresizingMaskIntoConstraints = false
答案 1 :(得分:0)
目标是将UIView
的开头,结尾,顶部和底部约束设置为其superview
的开头,结尾,顶部和底部约束
FIRE.translatesAutoresizingMaskIntoConstraints = false
FIRE.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
FIRE.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
FIRE.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
FIRE.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true