- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个 calendarTableVIew
与自定义单元格。细胞只有 dayLabel
在它们中,对于内容 View ,我分配了一个边框只是为了勾勒出单元格和背景颜色。决定我想要单元格之间有一个空格,我添加了 dayView
现在有轮廓的边框,以及 dayLabel
在里面。calendarTableview
当前单元格边框具有不同的颜色。问题是,自从我添加了新的 dayView
对于单元格,当前日期单元格以及任何选定的单元格,当您选择任何一天时,现在有一个黑色边框,并且 didDeselect
没有t change it to default anymore.
查看
I tried to give( contentView ) a rounded outline to see what effects it would produce and I can indeed see the rounded
查看, the
日视border, and the
dayLabel`参数全部受影响。你能看出那个黑色矩形是从哪里来的吗?我好像找不到。一如既往,非常感谢您的时间和帮助。
这是单元格:
这是代码(注释掉的部分是添加新 View 之前的代码):
自定义单元格:
class CalendarTableViewCell: UITableViewCell {
@IBOutlet weak var view: UIView! // added after errror has began but didn't solve it
@IBOutlet weak var dayView: UIView!
@IBOutlet weak var dayLabel: UILabel!
var cellDate : String!
var cellId: String!
var cellWeekday: Int!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
configureUi()
}
override func prepareForReuse() {
super.prepareForReuse()
// Set your default background color, title color etc
configureUi()
}
func configureUi() {
self.backgroundColor = UIColor.red
self.isOpaque = false
view.layer.cornerRadius = 5
view.layer.borderWidth = 0
view.clipsToBounds = true
dayView.layer.cornerRadius = 5
dayView.layer.borderWidth = 2
dayView.clipsToBounds = true
if Theme.selectedTheme == 1 {
if #available(iOS 11.0, *) {
view.layer.backgroundColor = UIColor.clear.cgColor//Theme.textFieldBackgroundColor?.cgColor//backgroundColor?.cgColor
view.layer.borderColor = UIColor.purple.cgColor
dayView.layer.backgroundColor = Theme.textFieldBackgroundColor?.cgColor
dayView.layer.borderColor = Theme.secondTintColor?.cgColor
dayLabel.layer.backgroundColor = Theme.textFieldBackgroundColor?.cgColor//labelBackgroundColor?.cgColor
dayLabel.textColor = Theme.textFieldTextColor//labelTextColor
} else {
// Fallback on earlier versions
layer.backgroundColor = Theme.textFieldBackgroundColorRgb.cgColor//backgroundColorRgb.cgColor
dayView.layer.backgroundColor = Theme.textFieldBackgroundColorRgb.cgColor//backgroundColorRgb.cgColor
dayView.layer.borderColor = Theme.secondTintColorRgb.cgColor//calendarCellRgb.cgColor
dayLabel.layer.backgroundColor = Theme.textFieldBackgroundColorRgb.cgColor//labelBackgroundColorRgb.cgColor
dayLabel.textColor = Theme.textFieldTextColorRgb//labelTextColorRgb
}
} else if Theme.selectedTheme == 2 {
if #available(iOS 11.0, *) {
layer.borderColor = Theme.calendarCell2?.cgColor
layer.backgroundColor = Theme.backgroundColor2?.cgColor
dayLabel.layer.backgroundColor = Theme.labelBackgroundColor2?.cgColor
dayLabel.textColor = Theme.labelTextColor2
} else {
// Fallback on earlier versions
layer.borderColor = Theme.calendarCellRgb2.cgColor
layer.backgroundColor = Theme.backgroundColorRgb2.cgColor
dayLabel.layer.backgroundColor = Theme.labelBackgroundColorRgb2.cgColor
dayLabel.textColor = Theme.labelTextColorRgb2
}
}
}
// func configureUi() {
// layer.cornerRadius = 5
// layer.borderWidth = 2
// clipsToBounds = true
// if Theme.selectedTheme == 1 {
// if #available(iOS 11.0, *) {
// layer.borderColor = Theme.calendarCell?.cgColor
// layer.backgroundColor = Theme.backgroundColor?.cgColor
// dayLabel.layer.backgroundColor = Theme.labelBackgroundColor?.cgColor
// dayLabel.textColor = Theme.labelTextColor
// } else {
// // Fallback on earlier versions
// layer.borderColor = Theme.calendarCellRgb.cgColor
// layer.backgroundColor = Theme.backgroundColorRgb.cgColor
// dayLabel.layer.backgroundColor = Theme.labelBackgroundColorRgb.cgColor
// dayLabel.textColor = Theme.labelTextColorRgb
// }
// } else if Theme.selectedTheme == 2 {
// if #available(iOS 11.0, *) {
// layer.borderColor = Theme.calendarCell2?.cgColor
// layer.backgroundColor = Theme.backgroundColor2?.cgColor
// dayLabel.layer.backgroundColor = Theme.labelBackgroundColor2?.cgColor
// dayLabel.textColor = Theme.labelTextColor2
// } else {
// // Fallback on earlier versions
// layer.borderColor = Theme.calendarCellRgb2.cgColor
// layer.backgroundColor = Theme.backgroundColorRgb2.cgColor
// dayLabel.layer.backgroundColor = Theme.labelBackgroundColorRgb2.cgColor
// dayLabel.textColor = Theme.labelTextColorRgb2
// }
// }
// }
}
表格 View :
extension WorkshopBookingsViewController: UITableViewDataSource, UITableViewDelegate {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return datesArray.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 60
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "calendarCell", for: indexPath) as! CalendarTableViewCell
// let cell = tableView.dequeueReusableCell(withIdentifier: "calendarCell") as! CalendarTableViewCell
cell.configureUi()
let date = datesArray[indexPath.row]
cell.cellDate = String( describing: date)
let calendar = Calendar.current
let components = calendar.dateComponents([.year, .month, .day, .weekday], from: date)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "EEEE"
let dayInWeek = dateFormatter.string(from: date)
// cell.dayLabel.text = "\(String(describing: components.day!))" + " " + "\(dayNamesArray[components.weekday! - 1])"
cell.dayLabel.text = "\(String(describing: components.day!))" + " " + dayInWeek
cell.cellWeekday = components.weekday!
// print("cell weekday is: \(cell.cellWeekday!)") // prints correct weekday
cell.cellId = "\(String(format:"%04d", components.year!))" + "\(String(format:"%02d", components.month!))" + "\(String(format:"%02d", components.day!))"
self.selectedDate = cell.cellId // used for time slots cellId
// print("##################### selectedDate in tableview is :\(self.selectedDate) ")
// highlighting current day cell
if indexPath.row == self.actualDay - 1 && self.actualMonth == self.displayedMonth {
cell.layer.borderWidth = 4
if Theme.selectedTheme == 1 {
if #available(iOS 11.0, *) {
cell.dayLabel.backgroundColor = UIColor.blue
cell.dayLabel.layer.borderColor = UIColor.purple.cgColor
// cell.contentView.backgroundColor = UIColor.blue
cell.dayView.layer.borderColor = UIColor.blue.cgColor//Theme.firstTintColor?.cgColor
} else {
// Fallback on earlier versions
cell.dayView.layer.borderColor = Theme.firstTintColorRgb.cgColor
}
} else if Theme.selectedTheme == 2 {
if #available(iOS 11.0, *) {
cell.layer.borderColor = Theme.calendarCellToday2?.cgColor
} else {
// Fallback on earlier versions
cell.layer.borderColor = Theme.calendarCellTodayRgb2.cgColor
}
}
// print(" @@@@@@@@@@@@@@@@@@@@@@@@@@ selected cell weekday is: \(cell.cellWeekday!) @@@@@@@@@@@@@@@@@@@@ ")
self.selectedDate = cell.cellId
self.updateTimeSlots(selectedCell: cell)
}
// if indexPath.row == self.actualDay - 1 && self.actualMonth == self.displayedMonth {
//
// cell.layer.borderWidth = 4
// if Theme.selectedTheme == 1 {
// if #available(iOS 11.0, *) {
// cell.layer.borderColor = Theme.calendarCellToday?.cgColor
// } else {
// // Fallback on earlier versions
// cell.layer.borderColor = Theme.calendarCellTodayRgb.cgColor
// }
//
// } else if Theme.selectedTheme == 2 {
// if #available(iOS 11.0, *) {
// cell.layer.borderColor = Theme.calendarCellToday2?.cgColor
// } else {
// // Fallback on earlier versions
// cell.layer.borderColor = Theme.calendarCellTodayRgb2.cgColor
// }
// }
// // print(" @@@@@@@@@@@@@@@@@@@@@@@@@@ selected cell weekday is: \(cell.cellWeekday!) @@@@@@@@@@@@@@@@@@@@ ")
// self.selectedDate = cell.cellId
// self.updateTimeSlots(selectedCell: cell)
// }
return cell
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
if let cell = tableView.cellForRow(at: indexPath) as? CalendarTableViewCell {
cell.configureUi()
// highlighting current day cell
if indexPath.row == self.actualDay - 1 && self.actualMonth == self.displayedMonth {
cell.dayView.layer.borderWidth = 4
if Theme.selectedTheme == 1 {
if #available(iOS 11.0, *) {
cell.dayView.layer.borderColor = Theme.firstTintColor?.cgColor
} else {
// Fallback on earlier versions
cell.dayView.layer.borderColor = Theme.firstTintColorRgb.cgColor
}
} else if Theme.selectedTheme == 2 {
if #available(iOS 11.0, *) {
cell.dayView.layer.borderColor = Theme.calendarCellToday2?.cgColor
} else {
// Fallback on earlier versions
cell.layer.borderColor = Theme.calendarCellTodayRgb2.cgColor
}
}
// print(" @@@@@@@@@@@@@@@@@@@@@@@@@@ selected cell weekday is: \(cell.cellWeekday!) @@@@@@@@@@@@@@@@@@@@ ")
self.selectedDate = cell.cellId
}
}
// if let cell = tableView.cellForRow(at: indexPath) as? CalendarTableViewCell {
// cell.configureUi()
// // highlighting current day cell
// if indexPath.row == self.actualDay - 1 && self.actualMonth == self.displayedMonth {
// cell.layer.borderWidth = 4
// if Theme.selectedTheme == 1 {
// if #available(iOS 11.0, *) {
// cell.layer.borderColor = Theme.calendarCellToday?.cgColor
// } else {
// // Fallback on earlier versions
// cell.layer.borderColor = Theme.calendarCellTodayRgb.cgColor
// }
// } else if Theme.selectedTheme == 2 {
// if #available(iOS 11.0, *) {
// cell.layer.borderColor = Theme.calendarCellToday2?.cgColor
// } else {
// // Fallback on earlier versions
// cell.layer.borderColor = Theme.calendarCellTodayRgb2.cgColor
// }
// }
// // print(" @@@@@@@@@@@@@@@@@@@@@@@@@@ selected cell weekday is: \(cell.cellWeekday!) @@@@@@@@@@@@@@@@@@@@ ")
//
// self.selectedDate = cell.cellId
// }
// }
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let cell = tableView.cellForRow(at: indexPath) as? CalendarTableViewCell {
cell.layer.borderWidth = 4
if Theme.selectedTheme == 1 {
if #available(iOS 11.0, *) {
cell.dayView.layer.borderColor = Theme.backgroundColor?.cgColor
} else {
// Fallback on earlier versions
cell.dayView.layer.borderColor = Theme.firstTintColorRgb.cgColor
}
} else if Theme.selectedTheme == 2 {
if #available(iOS 11.0, *) {
cell.dayView.layer.borderColor = Theme.firstTintColor2?.cgColor
} else {
// Fallback on earlier versions
cell.dayView.layer.borderColor = Theme.firstTintColorRgb2.cgColor
}
}
self.updateTimeSlots(selectedCell: cell)
}
// if let cell = tableView.cellForRow(at: indexPath) as? CalendarTableViewCell {
// cell.layer.borderWidth = 4
// if Theme.selectedTheme == 1 {
// if #available(iOS 11.0, *) {
// cell.layer.borderColor = Theme.firstTintColor?.cgColor
// } else {
// // Fallback on earlier versions
// cell.layer.borderColor = Theme.firstTintColorRgb.cgColor
// }
//
// } else if Theme.selectedTheme == 2 {
// if #available(iOS 11.0, *) {
//
// cell.layer.borderColor = Theme.firstTintColor2?.cgColor
// } else {
// // Fallback on earlier versions
// cell.layer.borderColor = Theme.firstTintColorRgb2.cgColor
// }
// }
// self.updateTimeSlots(selectedCell: cell)
// }
}
func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { // Error: this causes multiple index paths to be dequeed at tableview reload. call directly in cellForRowAt instead
// let cell: CalendarTableViewCell = tableView(self.calendarTableview, cellForRowAt: IndexPath.init(row: self.actualDay - 1, section: 0)) as! CalendarTableViewCell
// self.updateTimeSlots(selectedCell: cell)
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
// print("scrollViewDidEndDecelerating")
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if !decelerate {
// print("scrollViewDidEndDragging")
}
}
func scrollingFinish() -> Void {
// print("Scroll Finished!")
}
}
最佳答案
发现问题。当我添加新的 dayView
View 时,我为单元格本身指定了 self.backgroundColor
,但我还应该指定 self.layer.borderColor = UIColor。 clear.cgColor
,否则将获得默认的黑色。
这个细胞层有时会让我安静下来。所以在我的自定义单元格中,层是:
self(细胞本身)内容 View 添加 View 标签
并且您必须为每个图层指定backgroundColor
和borderColor
。希望这对其他人有帮助。干杯。
关于ios - 在 calendarTableView 自定义单元格中添加 View 破坏了代码 Swift 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58447430/
我已经尝试在我的 CSS 中添加一个元素来删除每三个 div 的 margin-right。不过,似乎只是出于某种原因影响了第 3 次和第 7 次。需要它在第 3、6、9 等日工作... CSS .s
如何使 div/input 闪烁或“脉冲”?例如,假设表单字段输入了无效值? 最佳答案 使用 CSS3 类似 on this page ,您可以将脉冲效果添加到名为 error 的类中: @-webk
我目前正在尝试构建一个简单的 wireframe来自 lattice 的情节包,但由沿 y 轴的数百个点组成。这导致绘图被线框网格淹没,您看到的只是一个黑色块。我知道我可以用 col=FALSE 完全
在知道 parent>div CSS 选择器在 IE 中无法识别后,我重新编码我的 CSS 样式,例如: div#bodyMain div#paneLeft>div{/*styles here*/}
我有两个 div,一个在另一个里面。当我将鼠标悬停 到最外面的那个时,我想改变它的颜色,没问题。但是,当我将鼠标悬停 到内部时,我只想更改它的颜色。这可能吗?换句话说,当 将鼠标悬停到内部 div 上
我需要展示这样的东西 有人可以帮忙吗?我可以实现以下输出 我正在使用以下代码:: GridView.builder( scrollDirection: Axis.vertical,
当 Bottom Sheet 像 Android 键盘一样打开时,是否有任何方法可以手动上推布局( ScrollView 或回收器 View 或整个 Activity )?或者你可以说我想以 Bott
我有以下代码,用于使用纯 HTML 和 CSS 显示翻转。当您将鼠标悬停在文本上时,它会更改左右图像。 在我测试的所有浏览器中都运行良好,Safari 4 除外。据我收集的信息,Safari 4 支持
我构建了某种 CMS,但在使用 TinyMCE 和 Bootstrap 时遇到了一些问题。 我有一个页面,其中概述了一个 div,如果用户单击该 div,他们可以从模态中选择图像。该图像被插入到一个
出于某种原因,当我设置一个过渡时,当我的鼠标悬停在一个元素上时,背景会改变颜色,它只适用于一个元素,但它们都共享同一个类?任何帮助我的 CSS .outer_ad { position:rel
好吧,这真的很愚蠢。我不知道 Android Studio 中的调试监视框架发生了什么。我有 1.5.1 的工作室。 是否有一些来自 intellij 的 secret 知识来展示它。 最佳答案 与以
我有这个标记: some code > 我正在尝试获取此布局: 注意:上一个和下一个按钮靠近#player 我正在尝试这样: .nextBtn{
网站:http://avuedesigns.com/index 首页有 6 个菜单项。我希望每件元素在您经过时都有自己的颜色。 这是当您将鼠标悬停在 div 上时将所有内容更改为白色的行 li#hom
我需要在 index.php 文件中显示它,但没有任何效果。我所有的文章都没有正确定位。我将其用作代码: 最佳答案 您可以首先检查您
我是一名优秀的程序员,十分优秀!