代码改变世界

UITableView从下往上加载cell CGAffineTransform

2018-09-18 11:08 by 法子, 968 阅读, 0 推荐, 收藏, 编辑
摘要:tableView是从上往下依次加载cell的。有时候想从下往上加载cell,比如聊天页面就是这样的,可以通过对tableView和其cell在y轴上缩放-1。来实现,当然, tableView.contentOffset.y的值、indexPaht的值也因此是从底部往上增长的。 override 阅读全文

indexPathsForSelectedRows被reloadData破坏

2018-09-17 15:43 by 法子, 1039 阅读, 0 推荐, 收藏, 编辑
摘要:参考文章:https://blog.csdn.net/a906335708/article/details/79300521 通过设置 或者实现协议 都可以由 或者有导航栏时添加左上角的编辑按钮,通过点击编辑按钮 进入编辑模式,来实现cell的多选,并且可以通过 来获取选中的indexPath。 但 阅读全文

push/pop 导航栏黑色阴影问题

2018-09-10 15:57 by 法子, 487 阅读, 0 推荐, 收藏, 编辑
摘要:原文:https://blog.csdn.net/thelittleboy/article/details/49001973 Toolbar类型,translucent = true,如果遮住的view有颜色,在push或pop时,都会有一部分颜色渐变区域。 当UITabBarController的 阅读全文

未调用preferredScreenEdgesDeferringSystemGestures和childViewControllerForScreenEdgesDeferringSystemGestures

2018-09-04 18:52 by 法子, 1233 阅读, 0 推荐, 收藏, 编辑
摘要:有一种原因会导致不调用重写的preferredScreenEdgesDeferringSystemGestures和childViewControllerForScreenEdgesDeferringSystemGestures函数。 就是新建了一个UIWindow,(默认isHidden = tr 阅读全文

swift实现类似宏定义功能,举例实现safeAreaInsets

2018-08-22 18:28 by 法子, 1929 阅读, 0 推荐, 收藏, 编辑
摘要://注意:要获取safeAreaInsets最好的办法是重写viewSafeAreaInsetsDidChange函数,在里面获取。因为viewDidLoad之前,safeAreaInsets是0值。并且屏幕也会转动。 override func viewSafeAreaInsetsDidChange () { print(view.safeAreaInsets.bott... 阅读全文

Swift自定义(可变参)打印函数

2018-08-22 17:48 by 法子, 550 阅读, 0 推荐, 收藏, 编辑
摘要:/// 单参数打印函数 /// /// - Parameters: /// - message:打印 /// - file: 文件名,默认值:#file /// - line: 第几行,默认值:#line /// - method: 函数名,默认值:#function func printLog(_ message:... 阅读全文

sizeToFit 和 sizeThatFits

2018-08-22 17:32 by 法子, 492 阅读, 0 推荐, 收藏, 编辑
摘要://文档//显示是UIView的extension。UILabel, UITextField, UITextView都可以调用 extension UIView { ... open func sizeThatFits(_ size: CGSize) -> CGSize // return 'best' size to fit given size. does not actua... 阅读全文

修改UITextfield的的默认的删除按钮图片

2018-08-22 17:09 by 法子, 2423 阅读, 0 推荐, 收藏, 编辑
摘要:UIButton *userNameClearButton = [self.usernameTextField valueForKey:@"_clearButton"]; [userNameClearButton setImage:[UIImage imageNamed:@"login_icon_clear"] forState:UIControlStateNormal]; 阅读全文

修改UITextfield的Placeholder字体的颜色

2018-08-22 17:05 by 法子, 440 阅读, 0 推荐, 收藏, 编辑
摘要://两种办法 //attributedPlaceholder self.usernameTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"xxx" attributes:@{NSForegroundColorAttributeName: [UIColor redCo... 阅读全文
上一页 1 ··· 5 6 7 8 9