1、取消估算高度:
tableView.cancelEstimatedHeight()
2、UIButton在设置不能交互的情况下如何让背景图片显示正常颜色:
https://blog.csdn.net/Mars_Liu_blog/article/details/52927670
3.Swift option错误Method cannot be a member of an @objc protocol because the type of the parameter 2 cannot be represented in Objective-C解决方法:
枚举前加上@objc即可。
4.在func前面加个@discardableResult,可以消除:函数调用后返回值未被使用的警告:
struct Point {
var x = 0.0, y = 0.0
@discardableResult mutating
func moveX(deltaX: Double) -> Double {
x += deltaX
return x
}
}
var p = Point()
p.moveX(deltaX: 10)
5.关键字mutating:
结构体和枚举是值类型,默认情况下,值类型的属性不能被自身的实例方法修改;
在func关键字前加mutating可以允许这种修改行为;
struct Point {
var x = 0.0, y = 0.0
mutating func moveBy(deltaX: Double, deltaY: Double) {
x += deltaX
y += deltaY
self = Point(x: x + deltaX, y: y + deltaY)
}
}
6.iOS 控制器多级Pop:
https://www.jianshu.com/p/4caddd76af12
7.iOS 更新Button title 闪动解决:
btn的type是custom,改成custom不会有闪烁情况.
8.坐标转换:
将countryCodeTextfield的frame转换到windown的frame:
guard let appDelegate = UIApplication.shared.delegate else { fatalError() }
guard let window = appDelegate.window else { fatalError() }
let rect = countryCodeTextfield.convert(countryCodeTextfield.frame, to: window)
print(rect)
selectCountryCodeView.frame = CGRect(x: rect.minX - 10, y: rect.maxY + 10, width: 200, height: 300)