Skip to content

Instantly share code, notes, and snippets.

struct AnimatedBarsGraph: View {
@State var arrayOfVal = [0.0,0.0,0.0,0.0,0.0,0.0,0.0]
@State var arrayOfRealVal = [100,250,170,100,130,120,130]
var body: some View {
HStack (alignment: .bottom){
ForEach (0..<arrayOfVal.count, id: \.self) { index in
RoundedRectangle(cornerRadius: 25)
.fill(.blue.opacity(0.4))
.frame(width: 36, height: arrayOfVal[index])
struct animatedView: View {
@State var opacity : CGFloat = 0.0
@State var yPosition : CGFloat = 80.0
var body: some View {
ZStack {
Text("HELLO WORLD!")
.font(.largeTitle).bold()
.foregroundColor(Color.teal)
.opacity(opacity)
struct AnimationModifier : ViewModifier{
let positionOffset : Double
let height = UIScreen.main.bounds.height
func body(content: Content) -> some View {
GeometryReader { geometry in
let position = geometry.frame(in: CoordinateSpace.global).midY
ZStack {
Color.clear
if height >= (position + positionOffset) {
struct ContentView: View {
var body: some View {
ZStack {
Circle()
.fill(Color.blue)
.frame(width: 12, height: 12)
.modifier(ParticlesModifier())
.offset(x: -100, y : -50)
Circle()
struct ParticlesModifier: ViewModifier {
@State var time = 0.0
@State var scale = 0.1
let duration = 5.0
func body(content: Content) -> some View {
ZStack {
ForEach(0..<80, id: \.self) { index in
content
.hueRotation(Angle(degrees: time * 80))
struct FireworkParticlesGeometryEffect : GeometryEffect {
var time : Double
var speed = Double.random(in: 20 ... 200)
var direction = Double.random(in: -Double.pi ... Double.pi)
var animatableData: Double {
get { time }
set { time = newValue }
}
func effectValue(size: CGSize) -> ProjectionTransform {
struct FinalSignUpView: View {
@State var email = ""
@State var password = ""
@State var passwordAgain = ""
var body: some View {
if #available(iOS 15.0, *) {
VStack{
Text("Sign up")
.font(.largeTitle)
struct ConcaveGlassView: ViewModifier {
func body(content: Content) -> some View {
if #available(iOS 15.0, *) {
content
.padding()
.frame(height: 50)
.background(.ultraThinMaterial)
.overlay(
RoundedRectangle(cornerRadius: 14)
.stroke(.linearGradient(colors:[.black,.white.opacity(0.75)], startPoint: .top, endPoint: .bottom), lineWidth: 2)
struct ConcaveGlassViewWithOverlay: ViewModifier {
func body(content: Content) -> some View {
if #available(iOS 15.0, *) {
content
.padding()
.frame(height: 50)
.background(.ultraThinMaterial)
.overlay(
LinearGradient(colors: [.black.opacity(0.2), .clear], startPoint: .top, endPoint: .bottom))
.cornerRadius(14)
struct ConvexGlassView: ViewModifier {
func body(content: Content) -> some View {
if #available(iOS 15.0, *) {
content
.padding()
.frame(height: 50)
.background(.ultraThinMaterial)
.cornerRadius(14)
.shadow(color: .white.opacity(0.65), radius: 1, x: -1, y: -2)
.shadow(color: .black.opacity(0.65), radius: 2, x: 2, y: 2)