问题描述
我正在设置一个底部按钮StackView,但我发现,只要设置它,我就会发现内存使用立即增加。
这是我在viewDidLoad()中实现的用于设置底部stackView的代码:
@objc fileprivate func setUPUI(){
let buttonsstackview = UIStackView(arrangedSubviews: [acceptButton,detailButton,cancelButton])
buttonsstackview.axis = .horizontal
buttonsstackview.distribution = .equalSpacing
buttonsstackview.alignment = .center
buttonsstackview.spacing = 20
//defining buttons Constraints
acceptButton.heightAnchor.constraint(equalToConstant: sideViewsSize).isActive = true
acceptButton.widthAnchor.constraint(equalToConstant: sideViewsSize).isActive = true
detailButton.heightAnchor.constraint(equalToConstant: centerViewSize).isActive = true
detailButton.widthAnchor.constraint(equalToConstant: centerViewSize).isActive = true
cancelButton.heightAnchor.constraint(equalToConstant: sideViewsSize).isActive = true
cancelButton.widthAnchor.constraint(equalToConstant: sideViewsSize).isActive = true
//setting shadows
acceptButton.setupShadow(opacity: 0.7,radius: 4,offset: .init(width: 0,height: 0),color: .darkGray)
detailButton.setupShadow(opacity: 0.7,color: .darkGray)
cancelButton.setupShadow(opacity: 0.7,color: .darkGray)
buttonsstackview.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(buttonsstackview)
buttonsstackview.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor,constant: -5).isActive = true
buttonsstackview.heightAnchor.constraint(equalToConstant: 90).isActive = true
buttonsstackview.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
buttonsstackview.leadingAnchor.constraint(greaterThanorEqualTo: view.leadingAnchor,constant: 20).isActive = true
buttonsstackview.trailingAnchor.constraint(lessthanorEqualTo: view.trailingAnchor,constant: -20).isActive = true
}
当我加载viewController时,它从41MB变为296MB
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)