我想UIImage
从一个创建一个对象UIView
.视图不是不透明的.因为我使用以下代码:
+ (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, [[UIScreen mainScreen] scale]);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
Run Code Online (Sandbox Code Playgroud)
但由于某些原因而不是透明背景我得到一个黑色背景的图像.我已经尝试将"opaque"参数设置UIGraphicsBeginImageContextWithOptions
为NO
但没有不同的结果.
有什么建议吗?
(类似问题CGContext透明度问题没有答案)
我在Watch中创建了一个会话并更新了Health Kit中的心率数据.现在,我想在iPhone屏幕上显示当前的心率.观察传感器更新健康套件中的心率数据,但iPhone应用程序无法从健康套件中获取实时数据.我已经测试了以下两种情况.我还使用计时器调用了这个方法/功能但它没有获得实时数据.
注意:当我打开Health App并重新打开我的应用程序时,它会自动刷新数据.如果我的应用程序持续处于前台,则代码下方不会刷新健康工具包中的最新数据
1.尝试使用HKSampleQuery获取实时心率数据
let calendar = NSCalendar.current
let components = calendar.dateComponents([.year, .month, .day], from: Date())
let startDate : NSDate = calendar.date(from: components)! as NSDate
let endDate : Date = calendar.date(byAdding: Calendar.Component.day, value: 1, to: startDate as Date)!
let predicate = HKQuery.predicateForSamples(withStart: startDate as Date, end: endDate, options:[])
//descriptor
let sortDescriptors = [NSSortDescriptor(key: HKSampleSortIdentifierEndDate, ascending: false)]
self.heartRateQuery = HKSampleQuery(sampleType: self.heartRateType, predicate: predicate, limit: 1, sortDescriptors: sortDescriptors, resultsHandler: { (query:HKSampleQuery, results:[HKSample]?, error:Error?) in
guard error == nil else { print("error …
Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中使用whatsapp将消息发送到其他手机.我已经看到了WhatsApp在Github上这个公共API,在这里.但我没有找到适用于iOS的API.那么可以在iOS应用程序中使用whatsapp吗?这合法吗?我在哪里可以找到适用于iOS的whatsapp的公共API?
CCMenu,CCMenuItem,CCMenuItemToggle切换在Cocos2d 3.0中已弃用.我想在cocos2d 3.0中设置切换按钮.
我在3.0中找到了下面的方法但它不起作用.
CCButton *soundOnBtn == [CCButton buttonWithTitle:@""
spriteFrame:[CCSpriteFrame frameWithImageNamed:@"soundOn.png"]
highlightedSpriteFrame:[CCSpriteFrame frameWithImageNamed:@"soundOnSelected.png"]
disabledSpriteFrame:nil];
CCButton *soundOffBtn= [CCButton buttonWithTitle:@""
spriteFrame:[CCSpriteFrame frameWithImageNamed:@"soundOff.png"]
highlightedSpriteFrame:[CCSpriteFrame frameWithImageNamed:@"soundOffSelected.png"]
disabledSpriteFrame:nil];
Run Code Online (Sandbox Code Playgroud)
请帮帮我...先谢谢你...
ios ×4
apple-watch ×1
healthkit ×1
iphone ×1
transparency ×1
uiimage ×1
uiview ×1
watch ×1
watchkit ×1
whatsapp ×1