Coder Social home page Coder Social logo

extensions's Introduction

swift-version swift-package-manager platforms CI license

Extensions ⚙️

A collection of useful Swift / SwiftUI extensions.

Content

Framework Extension Description
Foundation CGFloat+Degrees Provides convenient CGFloat constants for common angle measurements in radians. Examples:
- Rotate a view by 90 degrees:
view.transform = CGAffineTransform(rotationAngle: .degrees90)
- Set a circular progress bar to half:
progressBar.progress = .degrees180 / .degrees360
 Collection+Safe Avoids Fatal error: Index out of range (out of bounds index)
Returns the element at the specified index if it is within bounds; otherwise nil.
 Optional+ToString Allows printing nil when the optional is nil, or the wrapped value itself. For example: 123 instead of Optional(123).
 String+Decimal Formats a numeric string to a specified number of decimal places. For example: "351.6632141234" becomes "351.66".
 String+EmptyOrWhiteSpace Returns true if the string is empty or contains only whitespace and newline characters.
 String+Masking Hides sensitive information. Returns •••• when self is not empty.
 String+Split Returns the first component of the string up to, but not including, the first occurrence of a given separator.
Image I/O CGImagePropertyOrientation+CaseIterable Extends CGImagePropertyOrientation to conform to CaseIterable, providing a collection of all orientation cases.
 CGImagePropertyOrientation+CustomStringConvertible Makes CGImagePropertyOrientation instances print-friendly. Examples:
- print(orientation.description)
Output: Left (Rotated 90° CW (ClockWise)
- print(orientation.shortDescription)
Output: Up
- print(orientation.emoji)
Output (orientation is up/mirrored): ⬆️🪞
- print(orientation.emoji)
Output (orientation is unknown): 🤷🏻‍♂️
 CGImagePropertyOrientation+UIImage.Orientation Facilitates the conversion between CGImagePropertyOrientation and UIImage.Orientation, ensuring accurate mapping despite their differing underlying numeric values.
PhotoKit PHAssetMediaSubtype+CustomStringConvertible Makes PHAssetMediaSubtype instances print-friendly. Examples:
- print(phAssetMediaType.description)
Output: photoPanorama
- print(phAssetMediaType.description)
Output: videoHighFrameRate
 PHAssetMediaType+CustomStringConvertible Makes PHAssetMediaType instances print-friendly. Examples:
- print(phAssetMediaType.description)
Output: Image
- print(phAssetMediaType.description)
Output: Audio
SwiftUI FadeOut Fades out the edge of a view based on a given FadeOut.Edge.
 FrameSize Adds a dashed-colored frame-size container to a view for UI debugging.
 Shape+RoundedCorner Produces a shape with rounded corners. Allows specifying which corner is to be rounded. For example:
.cornerRadius(20, corners: [.topLeft, .bottomRight])
 StatefulPreviewWrapper Makes Xcode's preview canvas fully functional for previewing SwiftUI views that take @Bindings as input.
 View+Modify Allows applying view modifiers based on some criteria. For example:
Text("Some").modify { if someCondition { $0.bold() } }

SwiftUI Extension Screenshots

FadeOut FrameSize RoundedCorner
fadeOut frameSize roundedCorner

Integration

Xcode

Use Xcode's built-in support for SPM.

or...

Package.swift

In your Package.swift, add Extensions as a dependency:

dependencies: [
  .package(url: "https://github.com/backslash-f/extensions", from: "1.0.0")
]

Associate the dependency with your target:

targets: [
  .target(
    name: "YourAppName",
    dependencies: [
      .product(name: "Extensions", package: "extensions")
    ]
  )
]

Run: swift build

extensions's People

Contributors

backslash-f avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.