我正在尝试编写一个记录当前应用程序的脚本,切换到另一个应用程序,执行某项任务,然后返回到原始应用程序.这就是我所拥有的
set currentApp to my getCurrentApp()
activate application "Safari"
# Some task
activate application currentApp
to getCurrentApp()
set front_app to (path to frontmost application as Unicode text)
set AppleScript's text item delimiters to ":"
set front_app to front_app's text items
set AppleScript's text item delimiters to {""} --> restore delimiters to default value
set item_num to (count of front_app) - 1
set app_name to item item_num of front_app
set AppleScript's text item delimiters to "."
set app_name to app_name's text …Run Code Online (Sandbox Code Playgroud) for subView in searchBar.subviews {
if let scopeBar = subView as? UISegmentedControl {
scopeBar.backgroundColor = UIColor.blueColor()
}
}
Run Code Online (Sandbox Code Playgroud)
我一直在尝试上面的代码来尝试获得对scopeBar的引用,并随后设置其背景色,但是我无法获得引用。它似乎只循环一次,这意味着搜索栏只有一个子视图。在调试器中,搜索栏似乎具有一个名为_scopeBar的实例变量,其类型为(UISegmentedControl *)。
if let topView = searchBar.subviews.first {
for subView in topView.subviews {
if let cancelButton = subView as? UIButton {
cancelButton.tintColor = UIColor.whiteColor()
cancelButton.enabled = true
}
}
}
Run Code Online (Sandbox Code Playgroud)
第二段代码用于访问搜索栏的cancelButton。
当我从导航堆栈中弹出视图控制器时,弹出的导航控制器中的蓝色视图在离开屏幕时会出现延迟,并拖尾在视图控制器的其余部分后面,如视频所示:https : //vid.me /GbBG
这是什么原因,如何解决?