Commit 46b76c23b07cc2d9f18d4bcc75764a105e83ebb7
1 parent
ee22240b
首页频道适配文字多少适应宽度
Showing
1 changed file
with
60 additions
and
3 deletions
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVHomeViewController.swift
| @@ -89,7 +89,7 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | @@ -89,7 +89,7 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | ||
| 89 | }() | 89 | }() |
| 90 | lazy var pageStyleBtn2: QMUIButton = { | 90 | lazy var pageStyleBtn2: QMUIButton = { |
| 91 | let playBtn = QMUIButton.init(type: .custom) | 91 | let playBtn = QMUIButton.init(type: .custom) |
| 92 | - playBtn.frame = CGRect(x: pageStyleBtn1.right+10, y: self.searBarView.bottom+20, width: 80, height: 25) | 92 | + playBtn.frame = CGRect(x: pageStyleBtn1.right, y: self.searBarView.bottom+20, width: 60, height: 25) |
| 93 | playBtn.setTitle("影视剧", for: .normal) | 93 | playBtn.setTitle("影视剧", for: .normal) |
| 94 | playBtn.setTitleColor(HexColor("#919191"), for: .normal) | 94 | playBtn.setTitleColor(HexColor("#919191"), for: .normal) |
| 95 | playBtn.titleLabel?.font = Font_14 | 95 | playBtn.titleLabel?.font = Font_14 |
| @@ -99,7 +99,7 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | @@ -99,7 +99,7 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | ||
| 99 | }() | 99 | }() |
| 100 | lazy var pageStyleBtn3: QMUIButton = { | 100 | lazy var pageStyleBtn3: QMUIButton = { |
| 101 | let playBtn = QMUIButton.init(type: .custom) | 101 | let playBtn = QMUIButton.init(type: .custom) |
| 102 | - playBtn.frame = CGRect(x: pageStyleBtn2.right+10, y: self.searBarView.bottom+20, width: 80, height: 25) | 102 | + playBtn.frame = CGRect(x: pageStyleBtn2.right, y: self.searBarView.bottom+20, width: 80, height: 25) |
| 103 | playBtn.setTitle("影视剧", for: .normal) | 103 | playBtn.setTitle("影视剧", for: .normal) |
| 104 | playBtn.setTitleColor(HexColor("#919191"), for: .normal) | 104 | playBtn.setTitleColor(HexColor("#919191"), for: .normal) |
| 105 | playBtn.titleLabel?.font = Font_14 | 105 | playBtn.titleLabel?.font = Font_14 |
| @@ -109,7 +109,7 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | @@ -109,7 +109,7 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | ||
| 109 | }() | 109 | }() |
| 110 | lazy var pageStyleBtn4: QMUIButton = { | 110 | lazy var pageStyleBtn4: QMUIButton = { |
| 111 | let playBtn = QMUIButton.init(type: .custom) | 111 | let playBtn = QMUIButton.init(type: .custom) |
| 112 | - playBtn.frame = CGRect(x: pageStyleBtn3.right+10, y: self.searBarView.bottom+20, width: 80, height: 25) | 112 | + playBtn.frame = CGRect(x: pageStyleBtn3.right, y: self.searBarView.bottom+20, width: 80, height: 25) |
| 113 | playBtn.setTitle("影视剧", for: .normal) | 113 | playBtn.setTitle("影视剧", for: .normal) |
| 114 | playBtn.setTitleColor(HexColor("#919191"), for: .normal) | 114 | playBtn.setTitleColor(HexColor("#919191"), for: .normal) |
| 115 | playBtn.titleLabel?.font = Font_14 | 115 | playBtn.titleLabel?.font = Font_14 |
| @@ -450,6 +450,21 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | @@ -450,6 +450,21 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | ||
| 450 | for (idx,mdl) in homePageListMdls.enumerated() { | 450 | for (idx,mdl) in homePageListMdls.enumerated() { |
| 451 | if idx == 0{ | 451 | if idx == 0{ |
| 452 | self.pageStyleBtn1.setTitle(mdl.showName, for: .normal) | 452 | self.pageStyleBtn1.setTitle(mdl.showName, for: .normal) |
| 453 | + var width = 60 | ||
| 454 | + if mdl.showName.count <= 2{ | ||
| 455 | + width = 60 | ||
| 456 | + }else if mdl.showName.count == 3{ | ||
| 457 | + width = 80 | ||
| 458 | + }else{ | ||
| 459 | + width = 100 | ||
| 460 | + } | ||
| 461 | + //x10 3字80 2字60 高25 y:self.searBarView.bottom+20 | ||
| 462 | + self.pageStyleBtn1.snp.makeConstraints { make in | ||
| 463 | + make.left.equalTo(10) | ||
| 464 | + make.width.equalTo(width) | ||
| 465 | + make.height.equalTo(25) | ||
| 466 | + make.top.equalTo(self.searBarView.snp.bottom).offset(20) | ||
| 467 | + } | ||
| 453 | self.changeBtn(btn: self.pageStyleBtn1, isHighLight: true) | 468 | self.changeBtn(btn: self.pageStyleBtn1, isHighLight: true) |
| 454 | self.pageStyleBtn1.isHidden = false | 469 | self.pageStyleBtn1.isHidden = false |
| 455 | // self.group.enter() | 470 | // self.group.enter() |
| @@ -457,14 +472,56 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | @@ -457,14 +472,56 @@ class CNLiveTVHomeViewController:CNLiveBaseViewController, UITableViewDataSource | ||
| 457 | 472 | ||
| 458 | }else if idx == 1{ | 473 | }else if idx == 1{ |
| 459 | self.pageStyleBtn2.setTitle(mdl.showName, for: .normal) | 474 | self.pageStyleBtn2.setTitle(mdl.showName, for: .normal) |
| 475 | + var width = 60 | ||
| 476 | + if mdl.showName.count <= 2{ | ||
| 477 | + width = 60 | ||
| 478 | + }else if mdl.showName.count == 3{ | ||
| 479 | + width = 80 | ||
| 480 | + }else{ | ||
| 481 | + width = 100 | ||
| 482 | + } | ||
| 483 | + self.pageStyleBtn2.snp.makeConstraints { make in | ||
| 484 | + make.left.equalTo(self.pageStyleBtn1.snp.right) | ||
| 485 | + make.width.equalTo(width) | ||
| 486 | + make.height.equalTo(self.pageStyleBtn1.snp.height) | ||
| 487 | + make.top.equalTo(self.pageStyleBtn1.snp.top) | ||
| 488 | + } | ||
| 460 | self.changeBtn(btn: self.pageStyleBtn2, isHighLight: false) | 489 | self.changeBtn(btn: self.pageStyleBtn2, isHighLight: false) |
| 461 | self.pageStyleBtn2.isHidden = false | 490 | self.pageStyleBtn2.isHidden = false |
| 462 | }else if idx == 2{ | 491 | }else if idx == 2{ |
| 463 | self.pageStyleBtn3.setTitle(mdl.showName, for: .normal) | 492 | self.pageStyleBtn3.setTitle(mdl.showName, for: .normal) |
| 493 | + var width = 60 | ||
| 494 | + if mdl.showName.count <= 2{ | ||
| 495 | + width = 60 | ||
| 496 | + }else if mdl.showName.count == 3{ | ||
| 497 | + width = 80 | ||
| 498 | + }else{ | ||
| 499 | + width = 100 | ||
| 500 | + } | ||
| 501 | + self.pageStyleBtn3.snp.makeConstraints { make in | ||
| 502 | + make.left.equalTo(self.pageStyleBtn2.snp.right) | ||
| 503 | + make.width.equalTo(width) | ||
| 504 | + make.height.equalTo(self.pageStyleBtn1.snp.height) | ||
| 505 | + make.top.equalTo(self.pageStyleBtn1.snp.top) | ||
| 506 | + } | ||
| 464 | self.changeBtn(btn: self.pageStyleBtn3, isHighLight: false) | 507 | self.changeBtn(btn: self.pageStyleBtn3, isHighLight: false) |
| 465 | self.pageStyleBtn3.isHidden = false | 508 | self.pageStyleBtn3.isHidden = false |
| 466 | }else if idx == 3{ | 509 | }else if idx == 3{ |
| 467 | self.pageStyleBtn4.setTitle(mdl.showName, for: .normal) | 510 | self.pageStyleBtn4.setTitle(mdl.showName, for: .normal) |
| 511 | + var width = 60 | ||
| 512 | + if mdl.showName.count <= 2{ | ||
| 513 | + width = 60 | ||
| 514 | + }else if mdl.showName.count == 3{ | ||
| 515 | + width = 80 | ||
| 516 | + }else{ | ||
| 517 | + width = 100 | ||
| 518 | + } | ||
| 519 | + self.pageStyleBtn4.snp.makeConstraints { make in | ||
| 520 | + make.left.equalTo(self.pageStyleBtn3.snp.right) | ||
| 521 | + make.width.equalTo(width) | ||
| 522 | + make.height.equalTo(self.pageStyleBtn1.snp.height) | ||
| 523 | + make.top.equalTo(self.pageStyleBtn1.snp.top) | ||
| 524 | + } | ||
| 468 | self.changeBtn(btn: self.pageStyleBtn4, isHighLight: false) | 525 | self.changeBtn(btn: self.pageStyleBtn4, isHighLight: false) |
| 469 | self.pageStyleBtn4.isHidden = false | 526 | self.pageStyleBtn4.isHidden = false |
| 470 | }else{ | 527 | }else{ |