c-Viorel / NeumorphicView

NeumoprhicView is a simple NSView subclass that demonstrates the way of creation neumorphic-like views on macOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NeumorphicView

Neumorphism (or Neo-skeuomorphism) is a modern iteration of a style of designing web elements, frames, screens, etc. known as Skeuomorphism. SO, Neumorphism is a witty (right?) combo of the words “New” and “Skeuomorphism”.

NeumoprhicView is a simple NSView subclass that demonstrates the way of creation neumorphic-like views on macOS.

Requirements

  • macOS 10.12+

Installation

NeumorphicView is available via Swift Package Manager.

dependencies: [
    .package(url: "https://github.com/Krivoblotsky/NeumorphicView.git", .upToNextMajor(from: "1.0.0"))
]

Or you can use Xcode 11+: Project -> Swift Packages -> "+".

Usage

//Import Module
import NeumorphicView

//Add to your superview or use Interface Builder 
let neumorphicView = NeumorphicView(frame: NSRect(x: 0, y: 0, width: 100, height: 100))
self.view.addSubview(neumorphicView)

Setup

NeumorphicView has several basic inspectable properties to play with.

@IBInspectable var cornerRadius: CGFloat = 10 {
    didSet { updateCornerRadius() }
}

@IBInspectable var blurRadius: CGFloat = 1 {
    didSet { updateBlurRadius() }
}

@IBInspectable var shadowDistance: CGFloat = 10 {
    didSet { updatePositions() }
}

@IBInspectable var bevelColor: NSColor = NSColor(hexString: "EFEEEE") {
    didSet { updateColors() }
}

@IBInspectable var convex: CGFloat = 0.0 {
    didSet { updateColors() }
}

Demo

See NeumorphicView.xcodeproj for the demo.

Screenshots

Links

License

MIT License

Copyright (c) 2021 Serg Krivoblotsky

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

NeumoprhicView is a simple NSView subclass that demonstrates the way of creation neumorphic-like views on macOS.

License:MIT License


Languages

Language:Swift 100.0%