Skip to content

Instantly share code, notes, and snippets.

View Taehyeon-Kim's full-sized avatar
:octocat:

Taehyeon Kim Taehyeon-Kim

:octocat:
View GitHub Profile
@Taehyeon-Kim
Taehyeon-Kim / VideoPlayerView.swift
Created March 15, 2024 12:39
SwiftUI: Fetch Video from the Photo Album
import AVKit
import PhotosUI
import SwiftUI
struct VideoTransferable: Transferable {
let url: URL
static var transferRepresentation: some TransferRepresentation {
FileRepresentation(contentType: .movie) { exporting in
return SentTransferredFile(exporting.url)
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
import Foundation
import Security
private let DataKey = "MyDataKey"
/**
* The KeychainResult class wraps an OSStatus that is returned from a keychain action. It vends KeychainErrors.
*/
struct KeychainResult {
let keychainError: OSStatus
@Taehyeon-Kim
Taehyeon-Kim / CustomTabBarController.swift
Created July 16, 2023 07:43
Custom TabBarController
import SnapKit
import UIKit
class TabBarController: UITabBarController {
// MARK: - Properties
private let TabBarHeight: CGFloat = 51
// MARK: - UI Components
@Taehyeon-Kim
Taehyeon-Kim / CollectionView+StackView.swift
Created January 6, 2023 15:36
CollectionView Example with StackView
import UIKit
import SnapKit
final class InnerCell: UICollectionViewCell {
// MARK: UI
let stack: UIStackView = {
let stack = UIStackView()
stack.axis = .vertical
stack.distribution = .fill
return stack
@Taehyeon-Kim
Taehyeon-Kim / GetStringSize.swift
Created October 28, 2021 03:36
String의 크기를 측정해보자.
// ViewController.swift에서 사용해본 테스트 코드
// 텍스트 배열을 가져와서 각각의 크기를 측정해보고 있다.
import UIKit
class ViewController: UIViewController {
var texts = [
"전체",
"오늘",
@Taehyeon-Kim
Taehyeon-Kim / CollectionViewCellDynamicWidth.swift
Created October 28, 2021 03:15
컬렉션 뷰 셀의 너비를 동적으로 조절하고 싶을 때, How to dynamically adjust the width of the collection view cell.
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: categoryTitles[indexPath.item].size(withAttributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 14)]).width + 20, height: 32)
}
@Taehyeon-Kim
Taehyeon-Kim / CheckFontName.swift
Last active October 28, 2021 03:17
프로젝트 내에서 정확한 폰트 이름을 알고 싶을 때
for fontFamily in UIFont.familyNames {
for fontName in UIFont.fontNames(forFamilyName: fontFamily) {
print(fontName)
}
}