swift3

Swift - UI Button Shadow Gradient

南笙酒味 提交于 2020-04-07 16:50:29
问题 I am trying to recreate a button like this in Swift: I have been able to create the gradient inside of the button accurately from Sketch using the help from here: Answered Question Now I am trying to recreate the glow effect behind the button. I was thinking creating a subview behind it and using a gaussian blur filter to draw it. Now I am stuck in how to implement this, and haven't found a good solution. The normal CALayer shadow doesn't work with gradients, and I am lost. Any help is

rotate CIImage around center with CIFilter

别说谁变了你拦得住时间么 提交于 2020-03-28 04:15:13
问题 I'm trying to rotate the pixel data of a CMSampleBuffer (coming from the camera) and display it in a UIImageView. I Don't want to rotate the view itself. It has to be the actual pixel data. I grab the feed, convert it to a CIImage and with a CIFilter I rotate it. I'm having trouble with setting the point around which it has to rotate. Right now it rotates around the lower left point. I want to rotate it around its center. func captureOutput(_ captureOutput: AVCaptureOutput!,

Odd behavior from UITabBar where background color only shows for one tab

不羁的心 提交于 2020-03-26 21:53:12
问题 I am using Swift 3 and I researched various methods to set the backgroundColor color of a UITabBar . The most simple method was to change the property in the didFinishLaunchingWithOptions of the AppDelegate . When I tried to do this, the UITabBar launches with the standard color, which is not my intended result. However, when I go to the next tab, the UITabBar color gets changed to my intended color. Following this, I tried to subclass my UITabBarController and I tried to set the background

Why is deinit not called until UIView is added to parent again?

旧街凉风 提交于 2020-03-20 06:25:50
问题 I have a UIView that am adding to a UIViewController and am generally testing de-initialization to make sure I am doing things right. But when I don't set the variable in my viewController to nil and only use .removeFromSuperView() , the deinit() method in UIView won't be called until I add the UIView another time then its called. But if I use removeFromSuperView() and set the variable to nil then deinit() is called right away. Why is that? Here's UIView() class: class TestView: UIView {

Why is deinit not called until UIView is added to parent again?

混江龙づ霸主 提交于 2020-03-20 06:25:38
问题 I have a UIView that am adding to a UIViewController and am generally testing de-initialization to make sure I am doing things right. But when I don't set the variable in my viewController to nil and only use .removeFromSuperView() , the deinit() method in UIView won't be called until I add the UIView another time then its called. But if I use removeFromSuperView() and set the variable to nil then deinit() is called right away. Why is that? Here's UIView() class: class TestView: UIView {

Why is deinit not called until UIView is added to parent again?

有些话、适合烂在心里 提交于 2020-03-20 06:25:34
问题 I have a UIView that am adding to a UIViewController and am generally testing de-initialization to make sure I am doing things right. But when I don't set the variable in my viewController to nil and only use .removeFromSuperView() , the deinit() method in UIView won't be called until I add the UIView another time then its called. But if I use removeFromSuperView() and set the variable to nil then deinit() is called right away. Why is that? Here's UIView() class: class TestView: UIView {

Taking screenshot of WKWebview with hardware accelerated content

冷暖自知 提交于 2020-03-17 11:41:24
问题 I am having serious trouble with taking screenshot of WKWebview content when there is hardware accelerated content (some specific casino games that are running inside iframe). So far I used the standard way of taking screenshot like everyone suggests: UIGraphicsBeginImageContextWithOptions(containerView.frame.size, true, 0.0) containerView.layer.render(in: UIGraphicsGetCurrentContext()!) //This line helps to fix view rendering for taking screenshot on older iOS devices containerView

In Swift 3, how do I get UnsafeRawPointer from Data?

筅森魡賤 提交于 2020-03-17 07:03:25
问题 According to the documentation of Data in Swift 3, there is an initializer that I can use to create a Data from UnsafeRawPointer. What I need actually is the opposite. I have a Data, and I want to create a UnsafeRawPointer that points to the bytes of the Data. Here's what I'm doing right now: 1. let data = <from some where> 2. let unsafePointer = UnsafeMutablePointer<UInt8>.allocate(capacity: data.count) 3. unsafePointer.initialize(to: 0, count: data.count) // is this necessary? 4. data

Swift enum associated values in Objective-C

点点圈 提交于 2020-03-16 06:49:57
问题 Is there a way to use new Swift3 enums with associated value in Objective-C? Is there a way to declare/bridge Swift3 enums with associated value in Objective-C, if I develop a library and want to give Swift3 users convenient API? 回答1: I'm afraid it's not possible, Apple has a list of Swift Type Compatibility which explicitly excludes enumerations defined in Swift without Int raw value type. Reference 回答2: This is what I did: In Swift class created the enum enum Origin { case Search(searchTerm

Ambiguous reference to member Swift 3

半城伤御伤魂 提交于 2020-03-13 06:05:15
问题 I am migrating my project from Swift 2.3 to Swift 3. And having difficulty as expected. Here is a function which is being used for OAuth, using OAuthSwift. I have tried to convert class func OAuthSwiftAuthorization(inViewController viewController: UIViewController, withOAuthInfo info:FitnessTracker, successHandler:@escaping MyOAuthNewSuccessHandler, failure: @escaping ((_ error: NSError) -> Void)) { let oauthswift = OAuth2Swift( consumerKey: info.consumerKey, consumerSecret: info