![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Swift 点滴笔记
YY_Seven
这个作者很懒,什么都没留下…
展开
-
Swift4.2 KVO监听
var observation: NSKeyValueObservation?override func viewDidLoad() {super.viewDidLoad()self.observation = self.downView.observe(\UIView.isHidden, options: [.new]) { (_, change) i...原创 2019-03-20 10:41:31 · 314 阅读 · 0 评论 -
swift 显示网络图片
let url = model?.photovar imageUrl: URL?if let string = url, let urlString = string.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { imageUrl = URL(string: urlString)}self.phot...原创 2019-09-12 17:22:28 · 1073 阅读 · 0 评论 -
swift 字符串的处理(map)
let timeText = "2019-10-10 00:00:00,2019-10-10 00:00:00|2019-10-10 00:00:00,2019-10-10 00:00:00"let mapBlock: ([String]) -> (String) = { (list) -> String in var startTimeString = list.firs...原创 2019-09-12 13:47:06 · 817 阅读 · 0 评论 -
swift 关于时间转换
let timeFormater = DateFormatter() timeFormater.dateFormat = "yyyy-MM-dd HH:mm:ss" if let timeDate = timeFormater.date(from: model.createTime!) { t...原创 2019-09-11 20:04:55 · 315 阅读 · 0 评论 -
Swift textView输入提示和字数限制以及剩余字数显示
// MARK: - UITextViewDelegate func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { if text.isEmpty == true && range...原创 2019-07-26 11:16:41 · 2289 阅读 · 0 评论 -
Swift 隐藏某一页面的返回按钮
self.navigationItem.leftBarButtonItem = nilself.navigationItem.hidesBackButton = true起初,只写第二行没有用,加上第一行,先置空,再隐藏就好了。原创 2019-04-12 15:16:18 · 1101 阅读 · 1 评论 -
Swift 弹出View,加到最上层
func addPdfView(_ sender: String) { let mview = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)) let closedBtn = UIButton(...原创 2019-04-11 13:21:56 · 3444 阅读 · 0 评论 -
Swift 读取本地txt文本数据及转换
//读本地 转换成json do catch是抓错 let path = Bundle.main.url(forResource: "productDetailInfo", withExtension: "txt") let data = try! Data(contentsOf: path!) do { let dict = try!...原创 2019-03-28 10:26:06 · 3529 阅读 · 0 评论 -
Swift 取数组的前8个放到另一个数组里
//获取数据func setLocalData() { self.showHUD() self.task = FetchManager.share.fetchBrandList( success: { [unowned self] (list) -> (Void) in DispatchQueue.m...原创 2019-04-01 11:11:21 · 6224 阅读 · 0 评论 -
Swift WKWebView的url带汉字,页面加载不出来的解决办法
newUrlString = getUrlString?.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)原创 2019-03-26 17:11:28 · 1886 阅读 · 0 评论 -
swift获取版本号、获取缓存、清除缓存
// 获取App的版本号 self.version.text = infoDic?["CFBundleShortVersionString"] as? String///获取APP缓存 func getCacheSize()-> String { // 取出cache文件夹目录 let cachePath = NSSearchPathFo...原创 2019-03-26 15:00:47 · 624 阅读 · 0 评论 -
Swift 如何创建N个按钮,并且控件大小随着获取的文字长度变化
nameList!.forEach { (text) in let attributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14)] var width = (text.name?.boundingRect(with: ...原创 2019-03-22 17:58:51 · 628 阅读 · 0 评论 -
Swift 如何移除所有的子视图
自定义cell,如果self.contentView.addSubview(itemButton),再用的时候,一定记得先移除。self.contentView.subviews.forEach {$0.removeFromSuperview()}否则,滑动tableView的时候,重影了。...原创 2019-03-22 17:54:20 · 2379 阅读 · 0 评论 -
swift 解决tableView点击上窜的问题
自动计算cell高度,当点击选择的时候,tableView会上窜,给Estimate 一个大概默认值就ok了。原创 2019-09-16 16:53:03 · 237 阅读 · 0 评论