gpt4 book ai didi

ios - 菜单选项卡出现问题。我正在使用 carbonKit 框架

转载 作者:行者123 更新时间:2023-11-28 10:43:44 26 4
gpt4 key购买 nike

我希望两个选项卡 (Hello World, Tab) 的宽度与 Controller 宽度相等。我把我的标签的完整代码。如果有人对此有建议。请给建议。我在等。快速评论和回答。

enter image description here

import UIKit
import CarbonKit

class ViewController: UIViewController, CarbonTabSwipeNavigationDelegate {

func generateImage(for view: UIView) -> UIImage? {
defer {
UIGraphicsEndImageContext()
}
UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, UIScreen.main.scale)
if let context = UIGraphicsGetCurrentContext() {
view.layer.render(in: context)
return UIGraphicsGetImageFromCurrentImageContext()
}
return nil
}

var iconWithTextImage: UIImage {
let button = UIButton()
let icon = UIImage(named: "home")
button.setImage(icon, for: .normal)
button.setTitle("Home", for: .normal)
button.setTitleColor(UIColor.blue, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 15)
button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 10)
button.imageEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 10)
button.sizeToFit()
return generateImage(for: button) ?? UIImage()
}

override func viewDidLoad() {
super.viewDidLoad()

let tabSwipe = CarbonTabSwipeNavigation(items: ["HELLO WORLD", "Tab"], delegate: self)
tabSwipe.setTabExtraWidth(40)
tabSwipe.insert(intoRootViewController: self)

}

func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {
guard let storyboard = storyboard else { return UIViewController() }
if index == 0 {
return storyboard.instantiateViewController(withIdentifier: "FirstViewController")
}
return storyboard.instantiateViewController(withIdentifier: "SecondTableViewController")
}

}

最佳答案

这对你有帮助。

首先像这样将carbonSegmentControl frame设置为Screen equal Width

var frameRect: CGRect = (carbonTabSwipeNavigation.carbonSegmentedControl?.frame)!
frameRect.size.width = UIScreen.main.bounds.size.width
carbonTabSwipeNavigation.carbonSegmentedControl?.frame = frameRect

然后写下这条等宽的线。

carbonTabSwipeNavigation.carbonSegmentedControl?.apportionsSegmentWidthsByContent = false

<强>1。等宽前

enter image description here

<强>2。等宽后

enter image description here

关于ios - 菜单选项卡出现问题。我正在使用 carbonKit 框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49361229/

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