Coder Social home page Coder Social logo

notchkit's Introduction

NotchKit

CI Status Version CocoaPods Carthage License Contact

NotchKit is a simple way to hide the notch on the iPhone X, and create a card-like interface for your apps. Inspired by this tweet from Sebastiaan de With:

I hope / wish that the 'iPhone 8' UI looks like this: using black OLED or wallpaper behind to make apps 'cards'. Would be beautiful. pic.twitter.com/mravS87NFy

โ€” Sebastiaan de With (@sdw) August 31, 2017

Here's what it looks like:

Demo

Requirements

  • Swift 4
  • iOS 8

Installation

NotchKit is available via CocoaPods and Carthage

CocoaPods

To install NotchKit using CocoaPods, add the following line to your Podfile:

pod 'NotchKit'

Carthage

To install NotchKit using Carthage, add the following line to your Cartfile:

github "HarshilShah/NotchKit"

Usage

Integrating NotchKit is extremely simple. Firstly, import NotchKit in the file where your AppDelegate is stored.

Next, replace the didFinishLaunchingWithOptions method with the following, swapping in your custom view controller's class in place of ViewController

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    window = NotchKitWindow(frame: UIScreen.main.bounds)
    let rootViewController = ViewController()
    window?.rootViewController = rootViewController
    window?.makeKeyAndVisible()
    return true
}

If you use Storyboards, you can instantiate your Storyboard and fetch the new rootViewController in code using the following, swapping in your Storyboard's class for Main:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let rootViewController = storyboard.instantiateInitialViewController()

If you target a version of iOS earlier than iOS 11, you can still use NotchKit by loading the NotchKitWindow conditionally using the #available syntax, as follows:

window = {
    if #available(iOS 11, *) {
        return NotchKitWindow()
    } else {
        return UIWindow()
    }
}()

And that's all, you're done!

Customisation

There are some customisation points offered in NotchKit.

You can adjust these from any view or view controller belonging to the window, by simply calling the window as a NotchKitWindow, as follows:

(view.window as? NotchKitWindow)?.propertyToCustomise = valueYouWantToSet

Target Devices

By default, NotchKit hides the status bar and home indicator on all devices. However if you choose you can limit this behaviour to just the iPhone X and have it do nothing on other devices by setting the shouldShowBarsOnlyOniPhoneX property to true.

Masked Edges

By default, NotchKit masks all edges where applicable. You can customise this behaviour using the maskedEdges property, which accepts a UIRectEdge object that specifies the edges you want to mask.

Corner Radius

You can customise the corner radius of the window, via the .cornerRadius property. This property is an enum and can either be .standard, which does all the maths for you to show an appropriate corner radius, or you can set a custom value by setting it to .custom(n), where n is a custom corner radius of your choice.

Author

Written by Harshil Shah. You can find me on Twitter.

License

NotchKit is available under the MIT license. See the LICENSE file for more info.


P.S.: This was made mostly as a joke while I was debating different ways to handle the iPhone X.

Apple's updated Human Interface Guidelines for the iPhone X explicitly call this out:

Don't mask or call special attention to key display features. Don't attempt to hide the device's rounded corners, sensor housing, or indicator for accessing the Home screen by placing black bars at the top and bottom of the screen. Don't use visual adornments like brackets, bezels, shapes, or instructional text to call special attention to these areas either.

I'm not sure if violating the HIG is often used as grounds for a rejection, however I wouldn't bet either way.

It only took me a couple of days using the simulator to realise that embracing the notch is the way forward. My intention with open-sourcing this was to make it easier for others to reach that conclusion as well.

#EmbraceTheNotch

notchkit's People

Contributors

harshilshah avatar muukii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notchkit's Issues

Content cut off

Im getting an issue where the content at the top of my viewcontroller is being clipped b/c of NotchKit. I was hoping that the library would shift the contents down instead of overlaying them. B/c of this, I have to remove this library since it wont work for my app. Hopefully in the future you plan on adding this in.

Cheers

New issue checklist

Against guidelines?

From Apple guidelines:

Don't attempt to hide the device's rounded corners, sensor housing, or indicator for accessing the Home screen by placing black bars at the top and bottom of the screen. Don't use visual adornments like brackets, bezels, shapes, or instructional text to call special attention to these areas either.

-[UIScreen isiPhoneX]: unrecognized selector sent to instance

Not really sure why this is happening. I set the extension and computed property to public and it didn't fix anything. Happens when updateCornerRadii() gets called in layoutSubviews().

Temporary fix: I added this

private var isiPhoneX: Bool {
      return screen.nativeBounds.height == 2436 && screen.nativeBounds.width  == 1125
}

to NotchKitWindow and replaced all instances of screen.isiPhoneX with isiPhoneX.

Apps that use this technique will be rejected by Apple

Hi there, the idea is good but there is this tiny rule on the iPhone X Human Interface Guidelines...

Don't mask or call special attention to key display features. Don't attempt to hide the device's rounded corners, sensor housing, or indicator for accessing the Home screen by placing black bars at the top and bottom of the screen. Don't use visual adornments like brackets, bezels, shapes, or instructional text to call special attention to these areas either.

https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/

:(

Property 'maskedEdges' not found on object of type 'NotchKitW

New issue checklist

if (@available(iOS 11, *)) {
NotchKitWindow *notchWindow = [[NotchKitWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// [notchWindow setMaskedEdges:UIRectEdgeNone];
notchWindow.maskedEdges = UIRectEdgeNone;
self.window = notchWindow;
} else {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
}

error is Property 'maskedEdges' not found on object of type 'NotchKitWindow *'

swift 4.0 var must add the @objc refs ==> https://stackoverflow.com/questions/45656671/unable-to-access-swift-class-from-objective-c-property-not-found-on-object-of

Not available on cocoapods

Not available on cocoapods

When i run "pod install" i get the following response:
[!] Unable to find a specification for NotchKit

This concept might lead to App Store rejection

Hey there!

I really like the concept as it looks much cleaner! However, it seems to interfere with Apples iOS Human Interface Guidelines, where placing black bars at the top of the screen is to be explicitly avoided:

Don't mask or call special attention to key display features. Don't attempt to hide the device's rounded corners, sensor housing, or indicator for accessing the Home screen by placing black bars at the top and bottom of the screen. Don't use visual adornments like brackets, bezels, shapes, or instructional text to call special attention to these areas either.

It might be worth mentioning this in the README, as this could lead to rejection by the Apple Store Review Team.

This violates Apple's iOS Human Interface Guidelines

As the title states, this violate's Apple's guidelines and can lead to removal of an app form the app store.

Don't mask or call special attention to key display features. Don't attempt to hide the device's rounded corners, sensor housing, or indicator for accessing the Home screen by placing black bars at the top and bottom of the screen. Don't use visual adornments like brackets, bezels, shapes, or instructional text to call special attention to these areas either.

Source: https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/

Landscape issue

Hi, NotchKit is a great framework, and it works well at portrait pages:

portrait

But it has some issue at Landscape page(Some view is cropped too much):

landscape-error

The origin Landscape page is look like this:

landscape-correct

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.