在WWDC 2015上,有一个关于 iOS 9中新"旧金山"系统字体的会话.默认情况下,当与iOS 9 SDK链接时,它使用比例数字渲染而不是等宽数字.在NSFont上有一个方便的初始化程序NSFont.monospacedDigitsSystemFontOfSize(mySize weight:),可用于显式启用等宽数字显示.
但是,我无法找到UIKit相应的UIFont.
目前我有一张2048x435云的图像,使用CABasicAnimation滚动横跨面向大陆的UIDmageView 1024x435.云图像应该滚动,但是我在尝试获取重复的云图像以连接到当前云图像的背面时遇到了一些麻烦,因此云图像之间没有间隙.我一直在努力寻找一个解决方案,所以任何帮助都会非常感激.我目前的代码:
开发Xcode 4.2 for iOS 5,采用ARC非故事板ipad景观定位.
-(void)cloudScroll
{
UIImage *cloudsImage = [UIImage imageNamed:@"TitleClouds.png"];
CALayer *cloud = [CALayer layer];
cloud.contents = (id)cloudsImage.CGImage;
cloud.bounds = CGRectMake(0, 0, cloudsImage.size.width, cloudsImage.size.height);
cloud.position = CGPointMake(self.view.bounds.size.width / 2, cloudsImage.size.height / 2);
[cloudsImageView.layer addSublayer:cloud];
CGPoint startPt = CGPointMake(self.view.bounds.size.width + cloud.bounds.size.width / 2, cloud.position.y);
CGPoint endPt = CGPointMake(cloud.bounds.size.width / -2, cloud.position.y);
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"];
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
anim.fromValue = [NSValue valueWithCGPoint:startPt];
anim.toValue = [NSValue valueWithCGPoint:endPt];
anim.repeatCount = HUGE_VALF;
anim.duration = 60.0;
[cloud addAnimation:anim forKey:@"position"]; …Run Code Online (Sandbox Code Playgroud) 我正在尝试将函数传递给另一个函数,然后执行传递的函数传递给它一个变量.
这是我的代码:
func showStandardPrompt(prompt:String,view: UIViewController,numberInput: Bool, callback: (()->(String))?) {
let alert = UIAlertController(title: "Input Data", message: prompt, preferredStyle: .Alert)
alert.addTextFieldWithConfigurationHandler { (textField) in
if numberInput {
textField.keyboardType = .NumberPad
}
}
let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in
let field = alert.textFields![0] as UITextField
callback?(field.text!)
}
alert.addAction(OKAction)
let CancelAction = UIAlertAction(title: "Cancel", style: .Default, handler: nil)
alert.addAction(CancelAction)
view.presentViewController(alert,animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
callback?(field.text!)
Run Code Online (Sandbox Code Playgroud)
错误是"无法将'String'的值类型转换为期望的参数类型'()'.我知道这是语法问题 - 只是不知道应该是什么.
Ruby Motion刚刚问世,而截屏视频似乎没有说明是否可以使用Interface Builder构建接口并将它们集成到RubyMotion项目中.这样的事情可能吗?或者我真的手动编写所有代码,更不用说维护iPhone/iPad的不同代码了吗?
我的代表不够高,无法创建rubymotion标签,所以请在适当的时候帮忙.
我正在更新应用程序中的图标。听说Apple发布了SF Symbols以iOS 13 命名的图标字体后,我想知道我是否只能在iOS 13中使用它们,或者是否也可以在较低版本的iOS中使用它们。
如果要使用它们,是否必须对旧版本实施后备?
我有一个本地 Swift Package Manager 包,它使用私有 Github 存储库作为依赖项。当我使用 Xcode 打开本地包时,它无法 \xe2\x80\x9cResolve Packages\xe2\x80\x9d 并出现以下错误:
\n\n\n\n获取远程存储库时出错:git@github.com:mayoff/Preamble.git
\n\n\n服务器SSH指纹验证失败
\n
但是,如果我使用命令行swift程序,它可以克隆私有存储库。例如,我可以swift package show-dependencies毫无怨言地在本地包的目录中运行。我还可以使用 成功克隆远程包存储库git clone。所以这不是我的.known_hosts文件或 SSH 密钥的问题。
如何修复 Xcode 的投诉?
\n我想使用Xcode 9将iOS 11代码添加到我的项目中,同时保留使用仅支持iOS 10的Xcode 8编译项目的选项.
在Objective-C中,我可以通过使用预处理程序指令来检查是否__IPHONE_11_0已定义.如果我使用早于iOS 11的Base SDK进行编译,这将隐藏代码.像这样:
#ifdef __IPHONE_11_0
if (@available(iOS 11.0, *)) {
self.navigationController.navigationBar.prefersLargeTitles = YES;
}
#endif
Run Code Online (Sandbox Code Playgroud)
有没有办法在Swift中做到这一点?
if #available(iOS 11.0, *) 不起作用,因为这是一个运行时检查.
下面的代码很好地创建了一个由CGRect(rectRect)定义的圆角矩形.
它很好,但我没有中风.任何想法为什么我看不到中风?
-(void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(ctx, 0, 0, 0, 0.4);
CGContextSetRGBStrokeColor(ctx, 1, 1, 1, 1);
CGContextSetLineWidth(ctx, 4.0);
float fw, fh;
rect = rectRect;
float ovalWidth = 12;
float ovalHeight = 12;
if (ovalWidth == 0 || ovalHeight == 0) {
CGContextAddRect(ctx, rect);
return;
}
CGContextTranslateCTM (ctx, CGRectGetMinX(rect), CGRectGetMinY(rect));
CGContextScaleCTM (ctx, ovalWidth, ovalHeight);
fw = CGRectGetWidth (rect) / ovalWidth;
fh = CGRectGetHeight (rect) / ovalHeight;
CGContextMoveToPoint(ctx, fw, fh/2);
CGContextAddArcToPoint(ctx, fw, fh, fw/2, fh, 1);
CGContextAddArcToPoint(ctx, 0, fh, 0, …Run Code Online (Sandbox Code Playgroud) 我有一些警告在ios 7和8中运行良好.当我们使用iOS 9时,它给了我一个警告.
这是警告:
'appearanceWhenContainedIn:'已弃用:首先在iOS 9.0中弃用 - 使用+ appearanceWhenContainedInInstancesOfClasses:而不是
所以我使用了这段代码:
[[UITextField appearanceWhenContainedInInstancesOfClasses:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
Run Code Online (Sandbox Code Playgroud)
而不是这段代码:
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
Run Code Online (Sandbox Code Playgroud)
但是当我使用时,我得到了错误:
方法调用的参数太多,预期为1,有2个
警告:
'base64Encoding' is deprecated: first deprecated in iOS 7.0
在下面的代码中:
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64Encoding]];
Run Code Online (Sandbox Code Playgroud)
警告:
'searchDisplayController' is deprecated: first deprecated in iOS 8.0
在下面的代码中:
[self filterContentForSearchText:searchText scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
Run Code Online (Sandbox Code Playgroud)
警告:
'sendSynchronousRequest:returningResponse:error:' is deprecated: first deprecated in iOS 9.0 - Use [NSURLSession dataTaskWithRequest:completionHandler:] (see NSURLSession.h
在下面的代码中:
NSData *returnData = [NSURLConnection sendSynchronousRequest:request …Run Code Online (Sandbox Code Playgroud) 我有这个
Image(systemName: "arrow.right")
Run Code Online (Sandbox Code Playgroud)
但是我如何使其变为粗体,半粗体等?
我正在使用新的SwiftUI。
ios ×7
swift ×3
xcode ×3
objective-c ×2
sf-symbols ×2
callback ×1
cocoa-touch ×1
drawrect ×1
function ×1
github ×1
ios9 ×1
ipad ×1
macros ×1
monospace ×1
rubymotion ×1
ssh ×1
swiftui ×1
uifont ×1
uilabel ×1
versioning ×1