有没有办法自动调整UILabel的大小?给定尺寸为40 x 40时,文本字体大小将根据字符数进行调整.
我通常使用路径NSBundle.
但是,NSBundle不包含Documents文件夹.
如何获取Documents目录中文件的所有路径(或名称)?
我正在从swift 3转到swift 4.我有UILabels,我给标签提供了非常具体的文本属性.初始化strokeTextAttributes时,我在获取"意外发现nil时解包可选值"错误.坦白说,我完全迷失了.
在swift 3中,strokeTextAttributes是[String:Any],但是swift 4引发了错误,直到我将其更改为下面的内容.
let strokeTextAttributes = [
NSAttributedStringKey.strokeColor.rawValue : UIColor.black,
NSAttributedStringKey.foregroundColor : UIColor.white,
NSAttributedStringKey.strokeWidth : -2.0,
NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 18)
] as! [NSAttributedStringKey : Any]
chevronRightLabel.attributedText = NSMutableAttributedString(string: "0", attributes: strokeTextAttributes)
Run Code Online (Sandbox Code Playgroud) 我刚刚将我的应用程序从支持iOS 8改为支持iOS 9及更高版本.
由于我不使用故事板来创建我的视图,我想知道是否有编程方式的"使用安全区域指南"选项或类似的东西.
我试图锚定我的视图,但它们在iPhone X模拟器中保持顶部和底部重叠.
我有一个按钮,想要旋转里面的图像:
self.DashButton.imageView.transform = CGAffineTransformMakeRotation(M_PI);
用户点击图像后向上箭头向下箭头当再次点击按钮时,我希望向下箭头再次向上旋转向上箭头,但它是逆时针旋转相同,但我只想让箭头向后反转向上箭头
旋转代码:
self.DashButton.imageView.transform = CGAffineTransformIdentity;
我试过了
self.DashButton.imageView.transform = CGAffineTransformMakeRotation(-M_PI);
我想要的不是旋转整圆,只旋转180度和-180旋转,而不是360度全旋转
是否有人在Xcode 8中遇到代码折叠问题?每次我折叠GameScene.swift(或任何其他文件),切换到,例如AppDelegate.swift,然后切换回GameScene.swift(之前折叠),它展开.
在iPhone 6 plus上使用ARWorldTrackingSessionConfiguration获取和错误
Unable to run the session, configuration is not supported on this device
它能是什么?
我从 git 下载了一个用于目录的 Flutter 示例代码,它显示了一个警告,
'package get' 尚未运行
'Pub get' 尚未运行
这是什么意思?如何解决?我应该按照警告中的链接的建议忽略此警告或更新依赖项吗?
使用Swift 4.2,得到以下错误,这对Swift 4工作正常.
类型'NSNotification.Name'没有成员'UITextField'
这是我的错误代码.
NotificationCenter.default.addObserver(forName: NSNotification.Name.UITextField.textDidChangeNotification, object: textField, queue: OperationQueue.main) { (notification) in
loginAction.isEnabled = textField.text != ""
}
Run Code Online (Sandbox Code Playgroud)
完整代码:
@IBAction func alertWithLogin(){
let alertController = UIAlertController(title: "Please Enter Credential", message: nil, preferredStyle: .alert)
// ADD ACTIONS HANDLER
let loginAction = UIAlertAction(title: "Login", style: .default) { (_) in
let loginTextField = alertController.textFields![0] as UITextField
let passwordTextField = alertController.textFields![1] as UITextField
// do something with after login
}
loginAction.isEnabled = false
alertController.addAction(loginAction)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { …Run Code Online (Sandbox Code Playgroud) ios ×7
swift ×4
xcode ×4
objective-c ×3
ios11 ×2
uilabel ×2
arkit ×1
autolayout ×1
autoresize ×1
code-folding ×1
flutter ×1
iphone ×1
nsbundle ×1
swift4 ×1
swift4.2 ×1
xcode9 ×1
xcode9-beta ×1