Commit 3f24c198 authored by taorui's avatar taorui

feat :首页UI

parent 8a0939ba
{
"images" : [
{
"filename" : "sp-home-Back-Top.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-Back-Top@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-Back-Top@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-Start-Blue.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-Start-Blue@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-Start-Blue@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-Start-Green.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-Start-Green@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-Start-Green@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-Start-Red.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-Start-Red@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-Start-Red@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-Start-Yellow.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-Start-Yellow@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-Start-Yellow@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-blue.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-blue@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-blue@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-gray.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-gray@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-gray@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-green.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-green@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-green@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-orange.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-orange@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-orange@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-red.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-red@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-red@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-xyellow.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-xyellow@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-xyellow@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-book.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-book@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-book@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-clock.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-clock@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-clock@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-fire.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-fire@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-fire@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-flag.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-fresh.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-fresh@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-fresh@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-headerivar.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-pro.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-pro@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-pro@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-xuxianL.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-xuxianL@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-xuxianL@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sp-home-xuxianR.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sp-home-xuxianR@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sp-home-xuxianR@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
initData() initData()
SpeakElePublicManager.share.PublicData.state = .home
#if DEBUG #if DEBUG
// // 获取所有可用字体家族名称 // // 获取所有可用字体家族名称
// let fontFamilyNames = UIFont.familyNames // let fontFamilyNames = UIFont.familyNames
......
...@@ -39,3 +39,28 @@ public func Print(_ items: Any..., ...@@ -39,3 +39,28 @@ public func Print(_ items: Any...,
#else #else
#endif #endif
} }
/// 状态栏高度
var statusBarHeight: CGFloat {
// UIApplication.shared.statusBarFrame.height
UIApplication.shared.windows.first?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0.00
}
/// 导航栏高度
var naviBarHeight: CGFloat {
UINavigationController().navigationBar.frame.size.height
}
/// Tabbar高度
var tabbarHeight: CGFloat {
49.0 + tabbarSpace
}
/// Tabbar安全区域高度
var tabbarSpace: CGFloat {
isIphoneNotch ? 34 : 0
}
/// 是否刘海屏
var isIphoneNotch: Bool {
statusBarHeight > 20
}
...@@ -6,13 +6,123 @@ ...@@ -6,13 +6,123 @@
// //
import UIKit import UIKit
import SnapKit
class SpeakEleHomeViewCtr: SpeakEleBaseViewCtr { class SpeakEleHomeViewCtr: SpeakEleBaseViewCtr {
@IBOutlet weak var headerBoard: UIView!
lazy var mainScrollview: UIScrollView = {
let sView = UIScrollView()
sView.isUserInteractionEnabled = true
sView.isScrollEnabled = true
return sView
}()
lazy var levellb: UILabel = {
let lLabel = UILabel()
lLabel.text = "Entry-level"
lLabel.font = UIFont.montserrat(.regular ,size: 16)
lLabel.textColor = UIColor.init(with: "#000000", alpha: 0.4)
return lLabel
}()
lazy var leftline: UIView = {
let lineView = UIView()
lineView.backgroundColor = UIColor.init(with: "#000000", alpha: 0.4)
return lineView
}()
lazy var rightline: UIView = {
let lineV = UIView()
lineV.backgroundColor = UIColor.init(with: "#000000", alpha: 0.4)
return lineV
}()
lazy var topButton: UIButton = {
let button = UIButton.init(type: .custom)
button.setImage(UIImage(named: "sp-home-Back-Top"), for: .normal)
return button
}()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
makeUI()
makeLessonUI()
Print("输出状态栏高度\(statusBarHeight)")
}
var index = 4
var lessonIndex = 9
func makeUI() {
self.view.insertSubview(mainScrollview, belowSubview: headerBoard)
self.view.addSubview(topButton)
mainScrollview.addSubview(levellb)
mainScrollview.addSubview(leftline)
mainScrollview.addSubview(rightline)
mainScrollview.snp.makeConstraints { make in
make.top.equalTo(statusBarHeight + 137.0)
make.left.equalTo(24)
make.right.equalTo(-24)
make.bottom.equalTo(-100)
}
levellb.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(24)
}
leftline.snp.makeConstraints { make in
make.centerY.equalTo(levellb)
make.right.equalTo(levellb.snp.left).offset(-8)
make.left.equalTo(16)
make.height.equalTo(0.6)
}
rightline.snp.makeConstraints { make in
make.left.equalTo(levellb.snp.right).offset(8)
make.centerY.equalTo(levellb)
make.right.equalTo(self.view.snp.right).offset(-40)
make.height.equalTo(0.6)
}
topButton.snp.makeConstraints { make in
make.bottom.equalTo(-(tabbarHeight + 26))
make.right.equalTo(self.view.snp.right).offset(-16)
make.width.height.equalTo(48)
}
}
func makeLessonUI() {
let btnW = 96, btnH = 176
mainScrollview.contentSize = CGSize(width: mainScrollview.bounds.width, height: 1000)
for num in 0...index {
let bx = num % 2 == 0 ? -160 : -20
let backV = UIImageView(frame: CGRect(x: Int((Dev.screenW))/2 + bx, y: num * 158 + 100, width: 141, height: 162))
let iname = num % 2 == 0 ? "sp-home-xuxianL" : "sp-home-xuxianR"
backV.image = UIImage(named: iname)
mainScrollview.addSubview(backV)
}
for num in 0...lessonIndex {
let lview = SpeakEleLessionView()
lview.setColor(type: num)
if num == 0 {
lview.frame = CGRect(x: Int((Dev.screenW))/2-70, y: 55, width: btnW, height: btnH)
} else if num == 1{
lview.frame = CGRect(x: Int((Dev.screenW))/2-70, y: 55 + 56 + 96, width: btnW, height: btnH)
} else if num % 4 == 0{
lview.frame = CGRect(x: Int((Dev.screenW))/2-195, y: 120 + num * 80, width: btnW, height: btnH)
} else if num % 2 == 0{
lview.frame = CGRect(x: Int((Dev.screenW))/2+61, y: 120 + num * 80, width: btnW, height: btnH)
} else {
lview.frame = CGRect(x: Int((Dev.screenW))/2-70, y: 120 + num * 80, width: btnW, height: btnH)
}
mainScrollview.addSubview(lview)
}
} }
} }
//
// SpeakEleLessionView.swift
// SpeakEasyLearnEnglish
//
// Created by mac on 2025/7/15.
//
import UIKit
enum buttonColorType : String {
case red = "sp-home-red"
case blue = "sp-home-blue"
case yellow = "sp-home-xyellow"
case green = "sp-home-green"
case gray = "sp-home-gray"
case orange = "sp-home-orange"
}
class SpeakEleLessionView: UIView {
lazy var button: UIButton = {
let button = UIButton.init(type: .custom)
return button
}()
lazy var backView: UIView = {
let bView = UIView()
bView.backgroundColor = .white
return bView
}()
lazy var nameLb: UILabel = {
let nlb = UILabel()
nlb.font = UIFont.montserrat(.medium ,size: 14)
nlb.textColor = .black
nlb.text = "Music Prefences"
nlb.numberOfLines = 0
nlb.textAlignment = .center
return nlb
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.isUserInteractionEnabled = true
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setColor(type: Int) {
let colorArr: [buttonColorType] = [.blue,.orange,.green,.yellow,.red,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray]
button.setImage(UIImage(named: colorArr[type].rawValue), for: .normal)
}
private func setupUI() {
self.addSubview(backView)
backView.addSubview(button)
self.addSubview(nameLb)
backView.snp.makeConstraints { make in
make.width.height.equalTo(96)
make.top.left.right.equalTo(0)
}
nameLb.snp.makeConstraints { make in
make.top.equalTo(backView.snp.bottom).offset(5)
make.left.right.equalTo(0)
}
button.snp.makeConstraints { make in
make.top.equalTo(5)
make.left.equalTo(6)
make.right.equalTo(-6)
make.bottom.equalTo(-8)
}
backView.corners = 48
backView.borderWidth = 4
backView.borderColor = UIColor.init(with: "#000000", alpha: 0.18)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment