iOS

Custom UIButton edge insets

Since a button has an image and a title, it's easier to implement this design with UIButton. But it's not obvious how to custom the button, let's see how this works out. First, create relate code about the style and layout. lazy var button: UIButton = { let button = UIButton() button.setBackgroundColor(color: UIColor.black, forState: .normal) button.setImage(UIImage(named: "dot"), for: .normal) button.setTitleColor(.white, for: .normal) button.titleLabel?.font = UIFont.systemFont(ofSize: 13, weight: .semibold) button.layer.cornerRadius = 12 button.clipsToBounds = true return button }() view.addSubview(button)…

Keep reading

制作 App Store 预览视频

在 App Store 为 iOS 应用提供预览视频,可以让用户直观地了解应用的相关功能、提高浏览的转化率。下边介绍如何制作预览视频。 录制视频 视频需要至少提供5.5和6.5英寸两种尺寸,我们可以使用模拟器录制视频,节约成本。 在终端运行如下命令,开始录制视频: xcrun simctl io booted recordVideo app-preview.mp4 视频长度必须在15到30秒之间,同时为了方便用户观看,你可能需要调节操作的速度。 添加背景声 苹果要求视频必须带背景声,可以用下边的命令添加沉默的背景声。 ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i ./app_preview.mp4 -shortest -c:v copy -c:a aac ./app_preview_silence.mp4 编辑视频 打开 iMovie,新建视频预览项目,导入前面生成的视频文件。 编辑完视频文件后,点击右上角的分享按钮,选中最后一个项目导出视频。 最后在 iTunes Connect 上传视频后就大功告成了 🎉。 参考链接: https://help.apple.com/app-store-connect/?lang=zh-cn#/dev4e413fcb8 https://developer.apple.com/cn/support/app-previews/…

Keep reading

Custom Mapping in HandyJSON subclass

HandyJSON is a handy Swift JSON-Object serialization/deserialization library. Sometimes there is some special key in you JSON data, for example: { "description": "Hi" } Since description is a property of NSObject for "a textual representation of an object", it's not a good idea to map the JSON description to it, also it doesn't work if you want to. So we need to user Custom Mapping to map the value to another key, for example, desc: class BaseModel: NSObject, HandyJSON { required override init() {} } class ChildModel: BaseModel…

Keep reading

Fix layout issue for tableHeaderView

At times, there's some strange auto layout issue with tableHeaderView, the subview is either compressed or stretched. I check and re-check all constraints were set up correctly, it's especially frustrating. Here a container view come to rescue, the auto layout gets back to order if I put it in a container view. extension UITableView { // Fix headerView resize func setupHeaderView(_ headerView: UIView) { let headerContainerView = UIView(frame: headerView.frame) headerContainerView.addSubview(headerView) tableHeaderView = headerContainerView headerView.snp.makeConstraints { (make) -> Void in make.edges.equalTo(headerContainerView).inset(UIEdgeInsets.zero) } } }…

Keep reading

"error: unable to read SDK settings"

After I upgraded my MacBook to macOS Mojave, for every command executed in my Terminal I got error message like this: git: error: unable to read SDK settings for '/Library/Developer/CommandLineTools/SDKs/MacOSX10.12.sdk' git: error: unable to read SDK settings for '/Library/Developer/CommandLineTools/SDKs/MacOSX10.12.sdk' git: error: unable to read SDK settings for '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' git: error: unable to read SDK settings for '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' CommandLineTools was outdated, reinstalling Command Line Tools…

Keep reading