我想获得一个AVAsset视频文件大小,而不是视频的分辨率,但文件重量是KB.
一个解决方案是从持续时间和estimatedDataRate计算估计的文件大小,但这似乎只是为了获得文件大小.
我已经检查了嵌入AVAssetTrack其中的所有数据似乎没有在那里.即使是估计的文件大小也会很好.
我试图制作一个简单的应用程序,你触摸一个点,一个精灵跟随一条线穿过该点到屏幕的边缘,无论你在哪里触摸.我想绘制连接精灵的原点(它开始的点)和你触摸的点之间的线段,以及精灵的原点和屏幕边缘的终点之间的线段,这样我就可以看到精灵以及原点,触点和终点的x和y偏移之间的关系.
希望这不是太混乱.
TL; DR:我需要在两点之间画一条线,我不知道如何使用SpriteKit Swift.
提前致谢.
我创建了一个SKSpriteNode黑色的游戏,当用户触摸屏幕时,我希望将SKSpriteNode其更改为白色.我用谷歌搜索了所有可能的东西,尝试了许多不同的策略而没有运气.有谁知道如何做到这一点?
这是我的场景的代码:
var blackBird = SKSpriteNode()
override func didMoveToView(view: SKView) {
//Black Bird
var blackBirdTexture = SKTexture(imageNamed:"blackbird")
blackBirdTexture.filteringMode = SKTextureFilteringMode.Nearest
blackBird = SKSpriteNode(texture: blackBirdTexture)
blackBird.setScale(0.5)
blackBird.position = CGPoint(x: self.frame.size.width * 0.35, y:
self.frame.size.height * 0.6)
blackBird.physicsBody =
SKPhysicsBody(circleOfRadius:blackBird.size.height/2.0)
blackBird.physicsBody!.dynamic = true
blackBird.physicsBody!.allowsRotation = false
self.addChild(blackBird)
}
override func touchesBegan(touches: Set<NSObject, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
blackBird.color = .whiteColor()
blackBird.colorBlendFactor = …Run Code Online (Sandbox Code Playgroud) 我们如何在UIAlertcontroller中将归属文本设置为消息.我的尝试代码如下,但它会崩溃的应用程序.
// create Attributed text
let myAttribute = [NSForegroundColorAttributeName: UIColor(red:122.0/255, green:125.0/255, blue:131.0/255, alpha:1.0),NSFontAttributeName: Constant.flinntRegularFont(15)]
let myAttribute2 = [NSForegroundColorAttributeName: UIColor.blackColor(),NSFontAttributeName: Constant.flinntMediumFont(15)]
let myString = NSMutableAttributedString(string: "You have been unsubscribed from ", attributes: myAttribute)
let myString2 = NSMutableAttributedString(string: self.course.course_name, attributes: myAttribute2)
let myString3 = NSMutableAttributedString(string: "\n\nYour refund will be initiated within one week.", attributes: myAttribute)
let myString4 = NSMutableAttributedString(string: "\n\nFor any help call us on", attributes: myAttribute)
let myString5 = NSMutableAttributedString(string: " 079-4014 9800", attributes: myAttribute2)
let myString6 = NSMutableAttributedString(string: " between …Run Code Online (Sandbox Code Playgroud) 如何重新设置MKMapView回到世界视图缩放级别?
我想在两个日期之间生成一个随机日期 - 例如从今天到现在60天之间的随机日期.我怎么做?
UPDATE
使用答案中的信息,我想出了这个方法,我经常使用它:
// Generate a random date sometime between now and n days before day.
// Also, generate a random time to go with the day while we are at it.
- (NSDate *) generateRandomDateWithinDaysBeforeToday:(NSInteger)days
{
int r1 = arc4random_uniform(days);
int r2 = arc4random_uniform(23);
int r3 = arc4random_uniform(59);
NSDate *today = [NSDate new];
NSCalendar *gregorian =
[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *offsetComponents = [NSDateComponents new];
[offsetComponents setDay:(r1*-1)];
[offsetComponents setHour:r2];
[offsetComponents setMinute:r3];
NSDate *rndDate1 = [gregorian dateByAddingComponents:offsetComponents
toDate:today options:0]; …Run Code Online (Sandbox Code Playgroud) - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesBegan");
//test
UITouch *touch = [event allTouches] anyObject];
if ([touch tapCount] == 2) {
NSLog (@"tapcount 2");
[self.textview becomeFirstResponder];
}
else if ([touch tapCount] == 1) {
NSLog (@"tapcount 1");
[self.textview becomeFirstResponder];
[self.view performSelector:@selector(select:)];
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
NSLog(@"touchesMoved");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"****touchesEnded");
[self.nextResponder touchesEnded: touches withEvent:event];
NSLog(@"****touchesEnded");
[super touchesEnded:touches withEvent:event];
NSLog(@"****touchesEnded");
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesCancelled:touches withEvent:event];
NSLog(@"touchesCancelled");
}
Run Code Online (Sandbox Code Playgroud)
我的问题:
我想在a上点击一次时模拟两次点击UITextView …
我正在尝试减少ios的opencv2.framework大小.我的项目只使用core,imgproc和highgui模块.如何只使用那些模块进行编译?还是有减少尺寸的替代方案?
谢谢.
我正试图让元素在cercle的边缘移动.
var base = SKShapeNode(circleOfRadius: 200 ) // Size of Circle
base.position = CGPointMake(frame.midX, frame.midY)
base.strokeColor = SKColor.blackColor()
base.glowWidth = 1.0
base.fillColor = UIColor(hue:1, saturation:0.76, brightness:0.94, alpha:1)
base.zPosition = 0
self.addChild(base)
Run Code Online (Sandbox Code Playgroud)
main = SKSpriteNode(imageNamed:"Spaceship")
main.xScale = 0.15
main.yScale = 0.15
main.zPosition = 1
let circle = UIBezierPath(roundedRect: CGRectMake((self.frame.width/2) - 200, CGRectGetMidY(self.frame) - 200,400, 400), cornerRadius: 200)
let circularMove = SKAction.followPath(circle.CGPath, duration: 5.0)
main.runAction(SKAction.repeatAction(circularMove,count: 2))
self.addChild(main)
Run Code Online (Sandbox Code Playgroud)
宇宙飞船的第一次旋转(见下图)完全遵循圆的边缘,但第二次迭代改变了宇宙飞船的位置并将其移出屏幕边界.这是正常的还是我做错了什么?
谢谢.
简而言之,我想这样做,但要使用 SwiftUI。
(家应该被移除)
到目前为止,我还没有找到NavigationBarButton直接访问 的方法,并且设法找到了以下似乎是我迄今为止可以找到的修改按钮的唯一方法:
struct MyList: View {
var body: some View {
Text("MyList")
.navigationBarTitle(Text(verbatim: "MyList"), displayMode: .inline)
.navigationBarItems(leading: Text("<"))
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我丢失了默认的返回图像并得到了一个丑陋的 <。
ios ×8
swift ×4
sprite-kit ×3
cocoa ×2
cocoa-touch ×2
iphone ×2
avasset ×1
ios13 ×1
mkmapview ×1
objective-c ×1
opencv ×1
skspritenode ×1
swift2.3 ×1
swiftui ×1
tap ×1
uitextview ×1
uitouch ×1
xcode ×1