This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct SwitchLayouts : View{ | |
| @State private var switchStack: Bool = false | |
| var body: some View{ | |
| let layout = switchStack ? AnyLayout(HStack()) : AnyLayout(VStack()) | |
| VStack{ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Grid { | |
| GridRow { | |
| Color.red | |
| .gridCellColumns(2) | |
| Grid{ | |
| GridRow{ | |
| Color.orange | |
| } | |
| GridRow{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ZStack{ | |
| Circle().fill(.red.gradient.shadow(.drop(color: .black, radius: 10)).shadow(.inner(radius: 10))) | |
| .frame(width: 150, height: 150) | |
| Image(systemName: "swift") | |
| .resizable() | |
| .aspectRatio(contentMode: .fit) | |
| .frame(width: 75, height: 75) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension UIImage { | |
| class func imageFromColor(color: UIColor, size: CGSize=CGSize(width: 1, height: 1), scale: CGFloat) -> UIImage? { | |
| UIGraphicsBeginImageContextWithOptions(size, false, scale) | |
| color.setFill() | |
| UIRectFill(CGRect(origin: CGPoint.zero, size: size)) | |
| let image = UIGraphicsGetImageFromCurrentImageContext() | |
| UIGraphicsEndImageContext() | |
| return image | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func resizedImage(for size: CGSize) -> UIImage? { | |
| let image = self.cgImage | |
| let context = CGContext(data: nil, | |
| width: Int(size.width), | |
| height: Int(size.height), | |
| bitsPerComponent: image!.bitsPerComponent, | |
| bytesPerRow: Int(size.width), | |
| space: image?.colorSpace ?? CGColorSpace(name: CGColorSpace.sRGB)!, | |
| bitmapInfo: image!.bitmapInfo.rawValue) | |
| context?.interpolationQuality = .high |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import Vision | |
| class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { | |
| @IBOutlet weak var imageView: UIImageView! | |
| @IBOutlet weak var textView: UITextView! | |
| var animalRecognitionRequest = VNRecognizeAnimalsRequest(completionHandler: nil) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import CoreML | |
| enum Animal { | |
| case cat | |
| case dog | |
| } | |
| class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import coremltools | |
| coreml_model = coremltools.converters.keras.convert('model.h5', input_names=['image'], output_names=['output'],image_input_names='image') | |
| coreml_model.author = 'Anupam Chugh' | |
| coreml_model.short_description = 'Cat Dog Classifier converted from a Keras model' | |
| coreml_model.input_description['image'] = 'Takes as input an image' | |
| coreml_model.output_description['output'] = 'Prediction as cat or dog' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import Vision | |
| import VisionKit | |
| class ViewController: UIViewController, VNDocumentCameraViewControllerDelegate { | |
| @IBOutlet weak var imageView: UIImageView! | |
| @IBOutlet weak var textView: UITextView! | |
| var textRecognitionRequest = VNRecognizeTextRequest(completionHandler: nil) |
NewerOlder