ios8

Color from Green to Red with Percentage

杀马特。学长 韩版系。学妹 提交于 2021-02-19 04:58:45
问题 i am trying to create a custom UIColor from Green to Red depends on a Percentage Value, but i have no idea how can i do something like that? Any ideas? 回答1: Something along these lines should work, if you just want a linear mix: func mixGreenAndRed(greenAmount: Float) -> UIColor { return UIColor(red: (1.0 - greenAmount), green: greenAmount, blue: 0.0, alpha: 1.0) } That one will blend through RGB (0.5, 0.5, 0), though—a kind of ugly orange—so you might want to do this instead, which will just

UITextView UITextViewTextDidChangeNotification not being called on programmatic change of the text

五迷三道 提交于 2021-02-08 03:38:30
问题 I call this in the init of a custom UITextView: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChanged:) name:UITextViewTextDidChangeNotification object:self]; The method textChanged is not called when I programmatically set textView.text = @"" Any Ideas on what I am doing wrong? 回答1: Your shouldn't pass self to the last parameter, this parameter is notificationSender, it means that you just want to observer the notifications sent by self . Observer like this: [

UITextView with voiceover

时光毁灭记忆、已成空白 提交于 2021-02-07 11:20:17
问题 Here is my very simple code for creating a UITextView . UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds]; textView.editable = NO; textView.text = @"Using iOS 3.0 and later, VoiceOver is available to help users with visual impairments use their iOS-based devices. The UI Accessibility programming interface, introduced in iOS 3.0, helps developers make their applications accessible to VoiceOver users. Briefly, VoiceOver describes an application’s user interface and

PushKit notification not arriving after application kill AND device reboot

谁说我不能喝 提交于 2021-02-07 09:32:49
问题 My iOS application successfully receives VoIP push notifications even if it is closed, thanks to PushKit. There is only one condition when it fails: If I swipe my app out(terminate) throught the standard task switcher AND reboot my device. At first, I had this problem simply after rebooting the device, as described in this question: Troubleshooting post-boot push notification delivery failures A background task hack helped me, many thanks to the author, too bad I couldn't add any score. Now I

PushKit notification not arriving after application kill AND device reboot

自古美人都是妖i 提交于 2021-02-07 09:29:01
问题 My iOS application successfully receives VoIP push notifications even if it is closed, thanks to PushKit. There is only one condition when it fails: If I swipe my app out(terminate) throught the standard task switcher AND reboot my device. At first, I had this problem simply after rebooting the device, as described in this question: Troubleshooting post-boot push notification delivery failures A background task hack helped me, many thanks to the author, too bad I couldn't add any score. Now I

SCNText Alignment not working in iOS

随声附和 提交于 2021-02-07 07:19:42
问题 I tried right alignment, but it's still left aligned. let txt = SCNText(string: "TEST", extrusionDepth: 10) txt.chamferRadius = 5 //0<chamfer<extrusion depth txt.firstMaterial.diffuse.contents = UIColor.whiteColor() txt.containerFrame = CGRectMake(-200, -150, 400, 200) //on iPad Air Sim in Landscape txt.wrapped = true txt.alignmentMode = kCAAlignmentRight What is wrong? Thanks! 回答1: It looks like alignment is working -- try adding a second line to your test string like "TEST\nT" and switching

WKWebView Cache manifest not working IOS8

走远了吗. 提交于 2021-02-06 12:29:01
问题 Cache manifest works fine and events fired in safari in IOS 8. Not working at all in WKWebView anyone else solve this issue? import UIKit import WebKit class ViewController: UIViewController { @IBOutlet var containterView : UIView! = nil var webView : WKWebView? override func loadView(){ super.loadView() self.webView = WKWebView() self.view = self.webView! } override func viewDidLoad() { super.viewDidLoad() var url = NSURL(string:"http://html5demos.com/offlineapp") var req = NSURLRequest(URL

Custom UIWindows do not rotate correctly in iOS 8

∥☆過路亽.° 提交于 2021-02-06 08:47:11
问题 Get your application into landscape mode and execute the following code: UIWindow *toastWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; toastWindow.hidden = NO; toastWindow.backgroundColor = [[UIColor cyanColor] colorWithAlphaComponent:0.5f]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [toastWindow removeFromSuperview]; }); In iOS 7 you will get a transparent blue overlay on top of the entire screen that

UTTypeCreatePreferredIdentifierForTag and CFStringRef in Swift

烈酒焚心 提交于 2021-02-04 17:18:24
问题 import Foundation import MobileCoreServices func checkFileExtension(fileName: NSString){ println(fileName) var fileExtension:CFStringRef = fileName.pathExtension println(fileExtension) var fileUTI:CFStringRef = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, nil) println(fileUTI) let testBool = UTTypeConformsTo(fileUTI, kUTTypeImage) != 0 if testBool{ println("image") } } I get this error error : 'Unmanaged' is not convertible to 'CFStringRef' at line var

MapKit in Swift, Part 3 - MKPointAnnotation, addAnnotations

亡梦爱人 提交于 2021-01-28 21:34:32
问题 I'm trying work with Map Kit in Swift. I try to display the area on the map, some pins (MKPointAnnotation) and the current position. I decided to extend the class MKPointAnnotation - add a category. Class MyAnnotation.swift: import UIKit import MapKit class MyAnnotation: MKPointAnnotation { var category = Int() } I made an array of tuples to store information about the objects. In the loop I process all the elements of this array and make from it an array MyAnnotation . Then, I try to display