Skip to content

Instantly share code, notes, and snippets.

View rijieli's full-sized avatar
🍺

Roger Lee rijieli

🍺
View GitHub Profile
@import Photos;
[PHPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelReadWrite handler:^(PHAuthorizationStatus status) {
NSLog(@"PHAuthorizationStatus: %ld", status);
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
fetchOptions.includeHiddenAssets = YES;
fetchOptions.includeAllBurstAssets = YES;
PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithOptions:fetchOptions];
@rijieli
rijieli / MusicPlayerManager.swift
Created May 12, 2022 16:38 — forked from loretoparisi/MusicPlayerManager.swift
Ambiguous use of play of MPMusicPlayerController in iOS11, swift4 - Apple Example "Adding Content to Apple Music"
/*
See LICENSE folder for this sample’s licensing information.
Abstract:
The `MusicPlayerManager` manages the media playback using the `MPMusicPlayerController` APIs.
*/
import UIKit
import MediaPlayer
@rijieli
rijieli / ChineseTransliterator.swift
Created May 20, 2022 03:09
Transliterate Chinese between simplified and traditional (the wrong way).
import UIKit
struct ChineseTransliterator {
static func transliterate(text: String, sourceView: UIView) {
let textView = UITextView()
textView.isHidden = true
textView.text = text
textView.selectAll(nil)
sourceView.addSubview(textView)
@rijieli
rijieli / InfiniteScrollChart.swift
Created November 7, 2022 08:44 — forked from beader/InfiniteScrollChart.swift
Infinite Scrollable Bar Chart using Swift Charts
//
// InfiniteScrollChart.swift
// ChartsGallery
//
// Created by beader on 2022/11/3.
//
import SwiftUI
import Charts
@rijieli
rijieli / whenHovered.md
Created February 15, 2024 09:19 — forked from importRyan/whenHovered.md
Reliable SwiftUI mouse hover

Reliable mouseEnter/Exit for SwiftUI

Kapture 2021-03-01 at 14 43 39

On Mac, SwiftUI's .onHover closure is not always called on mouse exit, particularly with high cursor velocity. A grid of targets or with finer target shapes will often have multiple targets falsely active after the mouse has moved on.

It is easy to run back to AppKit's safety. Below is a SwiftUI-like modifier for reliable mouse-tracking. You can easily adapt it for other mouse tracking needs.

import SwiftUI
@rijieli
rijieli / gist:58abc113d032bd48ddd815b65d853582
Last active February 16, 2024 15:55 — forked from bakertim/gist:68a4c5778fb561ea34a4
Set iOS Build Number to Git Commit Count
# source http://blog.jaredsinclair.com/post/97193356620/the-best-of-all-possible-xcode-automated-build
#
# Set the build number to the current git commit count.
# If we're using the Dev scheme, then we'll suffix the build
# number with the current branch name, to make collisions
# far less likely across feature branches.
# Based on: http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/
#
git=`sh /etc/profile; which git`
@rijieli
rijieli / HelloAnimation.swift
Created February 24, 2024 09:14 — forked from amosgyamfi/HelloAnimation.swift
HelloAnimation.swift
//
// HelloAnimation.swift
// OpenvisionOS
//
// Created by Amos Gyamfi on 17.2.2024.
//
import SwiftUI
struct HelloAnimation: View {