gpt4 book ai didi

ios - SWRevealViewController 后 View 宽度未完全显示

转载 作者:行者123 更新时间:2023-11-30 12:53:24 29 4
gpt4 key购买 nike

我使用 SWRevealViewController 有前 View 和后 View 。我是新手(SWRevealViewController)。
当我点击前 View 中的导航菜单按钮时,我想要完全完整的后 View ,但它没有出现。
我已经尝试过,但我的后 View 最右边的按钮没有显示。有什么问题或者我必须添加一些额外的东西。
这是我的代码:-
前 View :-

class HomeViewController: UIViewController,SWRevealViewControllerDelegate {

@IBOutlet weak var openSlideMenuView: UIBarButtonItem!

override func viewDidLoad() {
super.viewDidLoad()


if self.revealViewController() != nil {

openSlideMenuView.target = self.revealViewController()
openSlideMenuView.action = #selector(SWRevealViewController.revealToggle(_:))

self.navigationController?.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}

}

谢谢

最佳答案

在我的设置中,我使用 UserDefault 来设置 mainViewController 中的这两个函数。

如果这是您正在寻找的答案,请不要忘记排除答案。

func changeShadow (){
let defaults: UserDefaults = UserDefaults.standard
let shadowColor = defaults.object(forKey: "shadowColorID") as? Int
if shadowColor == 1 {
revealViewController().frontViewShadowColor = UIColor.red
}else if shadowColor == 2{
revealViewController().frontViewShadowColor = UIColor.blue
}else if shadowColor == 3{
revealViewController().frontViewShadowColor = UIColor.green
}
}


func changeReveal (){
let defaults: UserDefaults = UserDefaults.standard
let revealWidth = defaults.object(forKey: "widthID") as? Int
if revealWidth == 1 {
revealViewController().rightViewRevealWidth = (view.frame.width / 5*4)
}else if revealWidth == 2{
revealViewController().rightViewRevealWidth = (view.frame.width / 6*5)
}else if revealWidth == 3{
revealViewController().rightViewRevealWidth = (view.frame.width / 7*6)
}else if revealWidth == 4{
revealViewController().rightViewRevealWidth = (view.frame.width / 8*7)
}else if revealWidth == 5{
revealViewController().rightViewRevealWidth = (view.frame.width )
}
}

在 SWRevealViewController.h 中查找第 241 行

// Defines how much of the rear or right view is shown, default is 260.
// Negative values indicate that the reveal width should be computed by substracting the full front view width,
// so the revealed frontView width is kept constant when bounds change as opposed to the rear or right width.
@property (nonatomic) CGFloat rearViewRevealWidth;
@property (nonatomic) CGFloat rightViewRevealWidth; // <-- simetric implementation of the above for the rightViewController

// Defines how much of an overdraw can occur when dragging further than 'rearViewRevealWidth', default is 60.
@property (nonatomic) CGFloat rearViewRevealOverdraw;
@property (nonatomic) CGFloat rightViewRevealOverdraw; // <-- simetric implementation of the above for the rightViewController

// Defines how much displacement is applied to the rear view when animating or dragging the front view, default is 40.
@property (nonatomic) CGFloat rearViewRevealDisplacement;
@property (nonatomic) CGFloat rightViewRevealDisplacement; // <-- simetric implementation of the above for the rightViewController

关于ios - SWRevealViewController 后 View 宽度未完全显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40691783/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com