Created
December 17, 2021 01:01
-
-
Save qoli/3259275a28f060b71b6bae05a948afcf to your computer and use it in GitHub Desktop.
modification.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// modification.swift | |
// Nomad | |
// | |
// Created by 黃佁媛 on 2021/12/17. | |
// | |
import Foundation | |
import SwiftUI | |
extension View { | |
@inlinable | |
func modify<T: View>(@ViewBuilder modifier: (Self) -> T) -> T { | |
return modifier(self) | |
} | |
} | |
extension View { | |
func iOS<Content: View>(_ modifier: (Self) -> Content) -> some View { | |
#if os(iOS) | |
return modifier(self) | |
#else | |
return self | |
#endif | |
} | |
} | |
extension View { | |
func macOS<Content: View>(_ modifier: (Self) -> Content) -> some View { | |
#if os(macOS) | |
return modifier(self) | |
#else | |
return self | |
#endif | |
} | |
} | |
extension View { | |
func tvOS<Content: View>(_ modifier: (Self) -> Content) -> some View { | |
#if os(tvOS) | |
return modifier(self) | |
#else | |
return self | |
#endif | |
} | |
} | |
extension View { | |
func watchOS<Content: View>(_ modifier: (Self) -> Content) -> some View { | |
#if os(watchOS) | |
return modifier(self) | |
#else | |
return self | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment