我从我的服务器获取UTC时区的字符串日期,我需要将其转换为本地时区.
我的代码:
let utcTime = "2015-04-01T11:42:00.269Z"
let dateFormatter = NSDateFormatter()
dateFormatter.timeZone = NSTimeZone(name: "UTC")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
let date = dateFormatter.dateFromString(utcTime)
println("utc: \(utcTime), date: \(date)")
Run Code Online (Sandbox Code Playgroud)
这个印刷品 -
utc:2015-04-01T11:42:00.269Z,日期:可选(2015-04-01 11:42:00 +0000)
如果我删除
dateFormatter.timeZone = NSTimeZone(name: "UTC")
Run Code Online (Sandbox Code Playgroud)
它打印
utc:2015-04-01T11:42:00.269Z,日期:可选(2015-04-01 08:42:00 +0000)
我的当地时区是UTC +3,在第一个选项中,我在第二个选项中得到UTC,我得到了UTC -3
我应该得到
utc:2015-04-01T11:42:00.269Z,日期:可选(2015-04-01 14:42:00 +0000)
那么如何将UTC日期格式转换为本地时间?
有没有办法按百分比划分屏幕(不等于百分比)我需要将屏幕分成两部分1/3和2/3.我知道如何分成相等的部分,但无法弄清楚如何分裂为不相等.
谢谢
有没有办法禁用Firebase分析自动屏幕报告?
我有几个UIViewCOntroller,我不想被报道.
所以我想管理报告我自己的屏幕.
设置FirebaseAutomaticScreenReportingEnabled到NO没有工作
谢谢
我需要动态地将UIDatePicker更改为特定的.
我的日期选择器仅设置为时间模式.我可以设定时间
timePicker.setDate(NSDate(), animated: false)
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何将其更改为不同的时间而不是当前时间.
那么我该怎么改呢?
谢谢
我正在创建一个自定义视图,我想要屏蔽并添加阴影.
掩蔽:
let p = UIBezierPath()
p.moveToPoint(CGPointMake(20, 20))
p.addLineToPoint(CGPointMake(100, 20))
p.addLineToPoint(CGPointMake(100, 50))
p.addLineToPoint(CGPointMake(110, 55))
p.addLineToPoint(CGPointMake(100, 60))
p.addLineToPoint(CGPointMake(100, 100))
p.addLineToPoint(CGPointMake(20, 100))
p.closePath()
let s = CAShapeLayer()
s.frame = layer.bounds
s.path = p.CGPath
s.fillColor = UIColor.greenColor().CGColor
layer.mask = s
Run Code Online (Sandbox Code Playgroud)
掩蔽工作,现在我想添加一个阴影.但它不起作用.
我试图在主图层添加阴影,没有任何反应.
layer.shadowColor = UIColor.yellowColor().CGColor
layer.shadowRadius = 10
layer.shadowOpacity = 0.9
layer.shadowOffset = CGSizeZero
Run Code Online (Sandbox Code Playgroud)
我试图将它添加到遮罩层,我得到了遮蔽阴影的主视图.
s.shadowColor = UIColor.yellowColor().CGColor
s.shadowRadius = 10
s.shadowOpacity = 0.9
s.shadowOffset = CGSizeZero
Run Code Online (Sandbox Code Playgroud)
有关如何将这个黄色阴影添加到蒙版视图的任何建议吗?
谢谢
我有一个@IBDesignable自定义视图.
我希望有一个最小高度.
如果我在代码中添加视图我覆盖
override init(frame: CGRect) {
let height = frame.height > minHeight ? minHeight : frame.height
let minFrame = CGRectMake(frame.origin.x, frame.origin.y, frame.width, height)
super.init(frame: minFrame)
}
Run Code Online (Sandbox Code Playgroud)
设置最小高度.
当在故事板中添加时
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
Run Code Online (Sandbox Code Playgroud)
叫做.
那我在哪里可以设置最小高度?
谢谢
我正在尝试使用google fit api来获取步数. 当我尝试粘贴代码时,我正在使用入门指南
private GoogleApiClient mClient = null;
Run Code Online (Sandbox Code Playgroud)
Android工作室找不到"com.google.android.gms.common.api"包和GoogleApiClient类.
我补充道
compile 'com.google.android.gms:play-services:7.0.0'
Run Code Online (Sandbox Code Playgroud)
我的朋友.
有什么建议?谢谢
编辑:
我改变了gradle以编译'com.google.android.gms:play-services:6.5.87'现在它可以工作了...有没有人知道为什么7.0.0不起作用?谢谢
我有一个带有动画图像的UImageview.我在代码中添加uiimageview,它是CollectionViewCell的一部分当用户触摸动画停止的单元格时,为什么会发生这种情况?
码:
var images: [UIImage] = []
for i in 0...10 {
images.append(UIImage(named: "image\(i)"))
}
let i = UIImageView(frame: CGRect(x: xPos, y: yPos, width: 200, height: 200))
i.animationImages = images
i.animationDuration = 0.5
i.startAnimating()
i.contentMode = UIViewContentMode.Center
i.userInteractionEnabled = false
self.addSubview(i)
Run Code Online (Sandbox Code Playgroud) 我想在用户点击推送通知时打开浏览器.
在我的应用代表中,我有:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var json = remoteNotif[UIApplicationLaunchOptionsRemoteNotificationKey] as! NSDictionary
storyboard = UIStoryboard(name: "Main", bundle: nil)
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let navC = storyboard.instantiateViewControllerWithIdentifier("mainNav") as! NavViewController
let data = json.objectForKey("data") as! NSDictionary
let url = data.objectForKey("url") as! String
UIApplication.sharedApplication().openURL(NSURL(string: url)!)
self.window?.rootViewController = navC
self.window?.makeKeyAndVisible()
}
Run Code Online (Sandbox Code Playgroud)
当用户点击推送通知时,这会给我一个黑屏20秒,然后打开应用程序,然后打开浏览器.如何只在浏览器上打开推送通知,或者至少打开超过20秒?
谢谢.
我需要一个项目中所有按钮的缩放弹簧动画.所以我将UIButton子类化并覆盖触摸事件函数.
import UIKit
class UIAnimatedButton: UIButton {
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
UIView.animateWithDuration(0.1, animations: { () -> Void in
self.transform = CGAffineTransformMakeScale(0.8, 0.8)
})
super.touchesBegan(touches, withEvent: event)
}
override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) {
UIView.animateWithDuration(0.5,
delay: 0,
usingSpringWithDamping: 0.2,
initialSpringVelocity: 6.0,
options: UIViewAnimationOptions.AllowUserInteraction,
animations: { () -> Void in
self.transform = CGAffineTransformIdentity
}) { (Bool) -> Void in
super.touchesCancelled(touches, withEvent: event)
}
}
override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
UIView.animateWithDuration(0.5,
delay: 0,
usingSpringWithDamping: …Run Code Online (Sandbox Code Playgroud) swift ×9
ios ×8
uiview ×2
android ×1
animation ×1
appdelegate ×1
calayer ×1
cashapelayer ×1
date ×1
firebase ×1
google-fit ×1
nsdate ×1
timezone ×1
uibutton ×1
uidatepicker ×1
uiimageview ×1