工作问题解决记录
2018-11-30 本文已影响24人
玉思盈蝶
1.Excel截取特定字符串前面的字符串:
=LEFT(A2,FIND("=",A2)-1)
2.Swift使用compactMap创建Button:
_ = buttons.enumerated().compactMap({ (index, value) -> UIButton in
let button = UIButton()
self.addSubview(button)
button.snp.makeConstraints({ (make) in
make.width.equalTo(btnWidth)
make.height.equalTo(45)
make.top.equalTo(self.centerView.snp.bottom).offset(23)
make.left.equalTo(self.centerView.snp.left).offset(CGFloat(index)*(btnWidth + 6))
})
button.setTitle(buttons[index].title, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 18)
button.layer.cornerRadius = 2.0
button.layer.masksToBounds = true
if buttons[index].isRed {
button.setTitleColor(UIColor.white, for: .normal)
button.backgroundColor = UIColor(hexString: "C23232")
}else {
button.setTitleColor(UIColor(hexString: "D5D5D5"), for: .normal)
button.backgroundColor = UIColor.clear
button.layer.borderWidth = 1.0
button.layer.borderColor = UIColor(hexString: "D5D5D5").cgColor
}
responseDic[button] = buttons[index].action
button.addTarget(self, action: #selector(buttonClick(btn:)), for: .touchUpInside)
return button
})
3.导入FrameWork,不能调用方法:
屏幕快照 2018-11-27 下午4.51.32.png4.删除数组重复元素:
let array: [String] = ["1011", "2022", "333", "444", "1011", "444"]
print("array = ", array)
// 删除数组重复元素
let result = Array(Set(array))
print("result = ", result)
5.报错:
A String substring is not Range<Int>, it's Range<String.index>
range可用于数组截取
let array = ["a", "b", "c", "d", "e"]
let a = array[2...3] //["c", "d"]
let b = array[2..<3] //["b"]
当然String不可以这样截取
6.设置Label字间距:
[attributedStr addAttribute:NSKernAttributeName value:@(10) range:NSMakeRange(0, attributedStr.length)];
以后这类的文章就这样设置标题咯~~~嘻嘻嘻