
User Achievements Badges
by dockui
Showcase earned and locked achievements with a stylish SwiftUI badge system. Includes user profiles, grid layouts, and dynamic visuals using SF Symbols.
- Platform
- SwiftUI
- Code
- Native Swift
- Format
- Screen
- Access
- Free
Code Snippet
import SwiftUI
struct UserBadgesAchievements: View {
var body: some View {
NavigationView {
ScrollView {
VStack(spacing: 32) {
// User Profile Section
VStack(spacing: 8) {
Image(systemName: "person.crop.circle.fill")
.resizable()
.frame(width: 80, height: 80)
.foregroundColor(.blue)
Text("John Doe")
.font(.title2)
.fontWeight(.bold)
Text("@johndoe")
.font(.subheadline)
.foregroundColor(.secondary)
}
.padding(.top, 16)
// Earned Badges
VStack(alignment: .leading, spacing: 16) {
Text("Your Badges")
.font(.headline)
.padding(.horizontal)
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())], spacing: 20) {
ForEach(earnedBadges) { badge in
BadgeView(badge: badge, locked: false)
}
}
.padding(.horizontal)
}
// Locked Badges
VStack(alignment: .leading, spacing: 16) {
Text("Locked Badges")
.font(.headline)
.padding(.horizontal)
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())], spacing: 20) {
ForEach(lockedBadges) { badge in
BadgeView(badge: badge, locked: true)
}
}
.padding(.horizontal)
}
}
.padding(.bottom, 32)
}
.navigationTitle("Achievements")
.background(
LinearGradient(gradient: Gradient(colors: [Color.blue.opacity(0.10), Color.purple.opacity(0.08)]), startPoint: .top, endPoint: .bottom)
.ignoresSafeArea()
)
}
}
}
struct UserBadge: Identifiable {
let id = UUID()
let icon: String // SF Symbol
let name: String
let level: String
}
let earnedBadges: [UserBadge] = [
.init(icon: "flame.fill", name: "Streak", level: "7 days"),
.init(icon: "star.fill", name: "Gold Member", level: "Level 3"),
.init(icon: "bolt.fill", name: "Active", level: "Level 2"),
.init(icon: "crown.fill", name: "Champion", level: "Top 10%"),
.init(icon: "heart.fill", name: "Supporter", level: "Level 1"),
.init(icon: "trophy.fill", name: "Winner", level: "3x")
]
let lockedBadges: [UserBadge] = [
.init(icon: "flame", name: "Streak Master", level: "30 days"),
.init(icon: "star", name: "Platinum", level: "Level 5"),
.init(icon: "bolt", name: "Ultra Active", level: "Level 5"),
.init(icon: "crown", name: "Legend", level: "Top 1%"),
.init(icon: "heart", name: "Super Supporter", level: "Level 5"),
.init(icon: "trophy", name: "Grand Winner", level: "10x")
]
struct BadgeView: View {
let badge: UserBadge
let locked: Bool
var body: some View {
VStack(spacing: 8) {
ZStack {
Circle()
.fill(locked ? Color(.systemGray5) : Color.blue.opacity(0.18))
.frame(width: 56, height: 56)
Image(systemName: badge.icon)
.font(.title2)
.foregroundColor(locked ? .gray : .blue)
}
Text(badge.name)
.font(.subheadline)
.fontWeight(.semibold)
.foregroundColor(locked ? .gray : .primary)
.lineLimit(1)
Text(badge.level)
.font(.caption)
.foregroundColor(locked ? .gray : .secondary)
.lineLimit(1)
}
.frame(width: 90)
.padding(8)
.background(
RoundedRectangle(cornerRadius: 16, style: .continuous)
.fill(Color(.systemBackground).opacity(locked ? 0.5 : 0.8))
)
}
}
More Templates
More Templates
View All TemplatesSimilar Blogs
View All Articles
How to Translate Xcode String Catalogs with AI
Learn how to efficiently translate Xcode string catalogs using AI fast, streamlining localization for your iOS and SwiftUI applications.

How to optimize your SwiftUI app in 2026
Discover top strategies to optimize your SwiftUI app in 2026, enhancing performance, responsiveness, and maintainability with modern concurrency.

SwiftUI: iOS Confirmation Alert (Confirm + Cancel)
SwiftUI iOS confirmation alert with Confirm and Cancel buttons. Beginners guide to building safe actions, destructive deletes, and commit dialogs.

SwiftUI: IOS Haptic Feedback Guide 2026
Add click to vibrate haptic feedback in SwiftUI. Full guide to UIImpactFeedbackgenerator, success, error, selection, and tap vibration patterns with code.
Code copied to clipboard!