UIStackView教程了解StackView

原地址

UIStackView简单介绍

一个Stack View能够将它所含的View以各种方式沿其轴向进行分布,同时也可以将View沿某个方向等距分布,要隐藏Stack View中的视图,你只需要设置该View的Hidden属性为true,剩下的工作Stack View会自己完成。。 坐标(Axis)、间隔(Spacing)、对齐(Alignment)以及分布(Distribution )等。 distribution属性:决定Stack View如何沿它轴向的水平方向摆放它的subview,当属性值是Fill,这表示subview会沿轴向完全占据Stack View。因此,Stack View会拉伸其中一个subview使其填充剩余空间,尤其是水平内容优先级最低的那个,如果所有subview优先级相同,则拉伸第一个subview。 Alignment属性:决定了Stack View如何沿它轴向的垂直方向摆放它的subview,对于一个垂直的Stack View,这个属性可以设置为Fill、Leading、Center和Trailing。 对于水平的Stack View,这个属性则稍有不同: .Top取代了.Leading,.Bottom取代了.Trailing。此外,水平Stack View还多出了两个属性值:.FirstBaseLine和.LastBaseLine。 对于水平的Stack View,这个属性则稍有不同: Fill: Leading: Center: Trailing:

更改设备屏幕上显示的应用程序图标下方的名称

修改APP启动图标上的名称,需配置Info.plist文件,增加CFBundleDisplayName属性键值对。 进入到如下界面:

Info.plist文件属性列表中搜索"Bundle display name",如果存在就修改为新APP名称。 如果不存在,在任何一个属性条目下,点击"+“按钮,弹出的下拉列表中选择"Bundle display name”,再双击"Bundle display name"属性值列,输入新APP名称。

自定义展示型控制器

{% github it-boyer PresentationsDemo 2cce4c908 width = 30% %}

触发转场的方式

官方支持的自定义转场

  • UINavigationControllerpushpop;
  • UITabBarController 中切换 Tab;
  • Modal 转场:presentationdismissal,俗称视图控制器的模态显示和消失,仅限于modalPresentationStyle属性为 UIModalPresentationFullScreenUIModalPresentationCustom 这两种模式; UICollectionViewController 的布局转场:仅限于 UICollectionViewControllerUINavigationController 结合的转场方式,与上面三种都有点不同,不过实现很简单,可跳转至该链接查看。 官方的支持包含了 iOS 中的大部分转场方式,还有一种自定义容器中的转场并没有得到系统的直接支持,不过借助协议这种灵活的方式,我们依然能够实现对自定义容器控制器转场的定制,在压轴环节我们将实现这一点。

相关触发转场的动作

UINavigationController

UINavigationController 中所有修改其viewControllers栈中 VC 的方法都可以自定义转场动画: {% codeblock swift lang:swift %} //我们使用的最广泛的 push 和 pop 方法 func pushViewController(_ viewController: UIViewController, animated animated: Bool) func popViewControllerAnimated(_ animated: Bool) -> UIViewController? //不怎么常用的 pop 方法 func popToRootViewControllerAnimated(_ animated: Bool) -> [UIViewController]? func popToRootViewControllerAnimated(_ animated: Bool) -> [UIViewController]? //这个方法有有点特别,是对 VC 栈的整体更新,开启动画后的执行比较复杂,具体参考文档说明。不建议在这种情况下开启转场动画。 func setViewControllers(_ viewControllers: [UIViewController], animated animated: Bool) {% endcodeblock %}

macOS支持JavaScript自动化组件基础

苹果 OS X Yosemite系统JavaScript作为 AppleScript的另一选择。AutomationOS X 10.10版本中的新特性,苹果在官网发布JavaScript for Automation Release Notes有篇文章介绍了用JavaScript写自动化Automation脚本。 JavaScript凭借其简单的语法,良好的性能,超轻量的框架,极小耦合的模块系统等等优势已经吸引了很多大厂的关注。 再加上JavaScript先天开放且无版权专利纠纷的问题,拥有非常广泛的开发者(开源)群体,苹果将其引入OS X平台代替私有的AppleScript,可能也有着一部分开放性平台的考虑,从而吸引广泛的第三方开发者。 资源 JavaScript OS X App Examples JavaScript for Automation Cookbook

通过沙盒中JS脚本访问其他APP

如何使用脚本字典里的命令和对象来与其他的应用进行通讯? 这个教程将向您展示现在使用 AppleScript 来控制别的应用的最佳方式。我也会告诉您一些小技巧以帮助您和您的用户用最小的努力就架设起 AppleScript

macOS之PDFKit基础

一个PDF的基本构建块是Documents本身。Documents通常作为文件存储在磁盘上。 作为文件版本,可以支持元数据标记如作者,创建日期,等等。 一个文件可以加密,需要密码才能查看它。两级加密存在:

Fabric对macOS系统的支持

Fabric

Fabric 是Twitter的移动应用开发平台,一个模块化、跨平台的移动开发套件,该博文主要研究crashlytics在app中的运用。 注册新的账户登录,审核通过时间为几个小时或者1到2天不等。然后注册时候输入的邮箱就会收到如下的邀请涵 浏览官方文档

crashlytics支持macOS

macOS的支持中出现的问题 问题:NSApplicationCrashOnExceptions is not set. This will result in poor top-level uncaught exception reporting 官方解释: {% blockquote 官方文档 https://docs.fabric.io/apple/crashlytics/os-x.html#macos-support macOS Support %} Uncaught Exceptions Intercepting and reporting uncaught exceptions on macOS is more complex than it is on iOS. On macOS, AppKit will catch exceptions thrown on the main thread, preventing the application from crashing, but also preventing Crashlytics from reporting them. To make matters worse, Apple’s frameworks are not exception safe. This means that while AppKit will prevent your app from crashing, it will also likely corrupt your process’s state, often including AppKit itself. Typically, once an exception involving UI interaction is thrown, it will prevent your app from working correctly from that moment on. Thankfully, AppKit has a little-known feature you can turn on to make the behavior much more predictable. We strongly recommend that you do the following in your application, right before you initialize Crashlytics. {% codeblock lang:objc %} [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @“NSApplicationCrashOnExceptions”: @YES }]; {% endcodeblock %}