Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View anupamchugh's full-sized avatar
🏠
Working from home

Anupam Chugh anupamchugh

🏠
Working from home
View GitHub Profile
struct SwitchLayouts : View{
@State private var switchStack: Bool = false
var body: some View{
let layout = switchStack ? AnyLayout(HStack()) : AnyLayout(VStack())
VStack{
Grid {
GridRow {
Color.red
.gridCellColumns(2)
Grid{
GridRow{
Color.orange
}
GridRow{
struct ShareLinkViews: View {
let link = URL(string: "https://www.iosdevie.com")!
var body: some View {
VStack(spacing: 10) {
ShareLink(item: link)
ShareLink(item: link) {
Text("Share Without Icon")
}
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)
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
}
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
import UIKit
import Vision
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var textView: UITextView!
var animalRecognitionRequest = VNRecognizeAnimalsRequest(completionHandler: nil)
import UIKit
import CoreML
enum Animal {
case cat
case dog
}
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
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'
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)