### Install via Carthage Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md Add this line to your Cartfile to include SDWebImageSVGCoder in your project. ```shell github "SDWebImage/SDWebImageSVGCoder" ``` -------------------------------- ### Install via Swift Package Manager Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md Add the SDWebImageSVGCoder repository to your Swift Package Manager dependencies. ```swift let package = Package( dependencies: [ .package(url: "https://github.com/SDWebImage/SDWebImageSVGCoder.git", from: "1.4.0") ] ) ``` -------------------------------- ### SVG Path CSS Opacity Issue Example Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md This HTML snippet demonstrates a crash scenario when a path element has both 'opacity' and 'fill' attributes defined with RGB color. Use RGBA for opacity instead. ```html ``` -------------------------------- ### Register SVG Coder (Swift) Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md Register the SDImageSVGCoder with the shared coders manager to enable SVG loading. This should typically be done in your AppDelegate. ```swift // register coder, on AppDelegate let SVGCoder = SDImageSVGCoder.shared SDImageCodersManager.shared.addCoder(SVGCoder) // load SVG url let imageView: UIImageView imageView.sd_setImage(with: url) // Changing size var rect = imageView.frame rect.size.width = 200 rect.size.height = 200 imageView.frame = rect; ``` -------------------------------- ### Load SVG as Bitmap Image (Objective-C) Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md Load an SVG image and specify a desired bitmap size using the SDWebImageContextThumbnailPixelSize option. This forces a bitmap representation. ```objectivec UIImageView *imageView; CGSize bitmapSize = CGSizeMake(500, 500); [imageView sd_setImageWithURL:url placeholderImage:nil options:0 context:@{SDWebImageContextThumbnailPixelSize: @(bitmapSize)]; ``` -------------------------------- ### Load SVG as Bitmap Image (Swift) Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md Load an SVG image and specify a desired bitmap size using the .imageThumbnailPixelSize context option. This forces a bitmap representation. ```swift let imageView: UIImageView let bitmapSize = CGSize(width: 500, height: 500) imageView.sd_setImage(with: url, placeholderImage: nil, options: [], context: [.imageThumbnailPixelSize : bitmapSize]) ``` -------------------------------- ### Register SVG Coder (Objective-C) Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md Register the SDImageSVGCoder with the shared coders manager to enable SVG loading. This should typically be done in your AppDelegate. ```objectivec // register coder, on AppDelegate SDImageSVGCoder *SVGCoder = [SDImageSVGCoder sharedCoder]; [[SDImageCodersManager sharedManager] addCoder:SVGCoder]; // load SVG url UIImageView *imageView; [imageView sd_setImageWithURL:url] // Changing size CGRect rect = imageView.frame; rect.size.width = 200; rect.size.height = 200; imageView.frame = rect; ``` -------------------------------- ### Set iOS Deployment Target for CocoaPods Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md For CocoaPods users, specify the platform version in your Podfile. This is a hint for CocoaPods and does not affect your App Target's deployment target version. ```ruby platform :ios, '13.0' # This does not effect your App Target's deployment target version, just a hint for CocoaPods ``` -------------------------------- ### SVG Path CSS Opacity Workaround Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md This HTML snippet shows the workaround for the CSS opacity issue by using 'rgba' in the 'fill' attribute to specify opacity. ```html ``` -------------------------------- ### Export SVG Data (Objective-C) Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md Export an SVG image (UIImage or NSImage with NSSVGImageRep) to its original SVG data format. This API is available from SDWebImage 5.6.0. ```objectivec UIImage *svgImage; // UIImage with vector image, or NSImage contains `NSSVGImageRep` if (svgImage.sd_isVector) { // This API available in SDWebImage 5.6.0 NSData *svgData = [svgImage sd_imageDataAsFormat:SDImageFormatSVG]; } ``` -------------------------------- ### Conditional SVG Coder Loading for Backward Deployment Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md Use runtime version checks to ensure symbols are available. This Objective-C snippet conditionally adds either SDImageSVGCoder or SDImageSVGKCoder to the coders manager based on the iOS version. ```objective-c if (@available(iOS 13, *)) { [SDImageCodersManager.sharedCoder addCoder:SDImageSVGCoder.sharedCoder]; } else { [SDImageCodersManager.sharedCoder addCoder:SDImageSVGKCoder.sharedCoder]; } ``` -------------------------------- ### Export SVG Data (Swift) Source: https://github.com/sdwebimage/sdwebimagesvgcoder/blob/master/README.md Export an SVG image (UIImage or NSImage with NSSVGImageRep) to its original SVG data format. This API is available from SDWebImage 5.6.0. ```swift let svgImage: UIImage // UIImage with vector image, or NSImage contains `NSSVGImageRep` if svgImage.sd_isVector { // This API available in SDWebImage 5.6.0 let svgData = svgImage.sd_imageData(as: .SVG) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.