mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-24 09:38:36 +02:00
Update
This commit is contained in:
45
Other Projects/Jike/SwiftUI_Jike/GYTabView.swift
Executable file
45
Other Projects/Jike/SwiftUI_Jike/GYTabView.swift
Executable file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// GYTabView.swift
|
||||
// SegmentDemo
|
||||
//
|
||||
// Created by alexyang on 2019/6/6.
|
||||
// Copyright © 2019 alexyang. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct GYTabView<Page: View>: View {
|
||||
var titles:[String]
|
||||
var imgs:[String]
|
||||
var imgSels:[String]
|
||||
var viewControllers: [UIHostingController<Page>]
|
||||
|
||||
init(_ views: [Page], titles: [String], images:[String], imageSels:[String]) {
|
||||
|
||||
let vc0 = UIHostingController(rootView: HomeView())
|
||||
let vc1 = UIHostingController(rootView: ActivityView())
|
||||
let vc2 = UIHostingController(rootView: ChatView())
|
||||
let vc3 = UIHostingController(rootView: SettingView())
|
||||
self.viewControllers = [vc0,vc1,vc2,vc3] as! [UIHostingController<Page>]
|
||||
self.titles = titles
|
||||
self.imgs = images
|
||||
self.imgSels = imageSels
|
||||
}
|
||||
|
||||
|
||||
var body: some View {
|
||||
|
||||
GYTabBarViewController(titles: titles, imgs: imgs, imgSels: imgSels, controllers: viewControllers)
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct GYTabView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
GYTabView([Text("haha"),Text("hah1"),Text("haa")],
|
||||
titles: ["tab1","tab2","tab3"],
|
||||
images: ["tab_home_normal","tab_chat_normal","tab_me_normal"],
|
||||
imageSels: ["tab_home_select","tab_chat_select","tab_me_select"])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user