Skip to content

Instantly share code, notes, and snippets.

View antranapp's full-sized avatar

An Tran antranapp

View GitHub Profile
import SwiftUI
struct ContentView: View {
@State var t: Float = 0.0
@State var timer: Timer?
var body: some View {
ZStack {
MeshGradient(
@antranapp
antranapp / CMSampleBufferRef_to_vImage.m
Created November 25, 2022 10:52 — forked from podkovyrin/CMSampleBufferRef_to_vImage.m
CMSampleBufferRef to vImage and resize
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer,0);
size_t height = CVPixelBufferGetHeight(imageBuffer);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
void *sourceData = CVPixelBufferGetBaseAddress(imageBuffer);
// Set a bunch of variables we need. The "radius" for the blur kernel needs to be positive and odd. The permute map maps the BGRA channels of the buffer to the ARGB that vImage needs.
@antranapp
antranapp / No Inset for TableViewCells
Created May 14, 2015 12:46
Remove Inset of TableViewCells
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.layoutMargins = UIEdgeInsetsZero
cell.separatorInset = UIEdgeInsetsZero
cell.preservesSuperviewLayoutMargins = false
}
@antranapp
antranapp / gist:89b1ebef5a0a984140a3
Created May 3, 2015 15:59
[iOS] Change title and tint color for navigation controller
self.navigationController?.navigationBar.barTintColor = UIColor.redColor()
self.navigationController?.navigationBar.translucent = false
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
- (void)setupMapSnapshot
{
CLLocationCoordinate2D coordinate = self.outlet.annotaion.coordinate;
MKMapSnapshotOptions* options = [MKMapSnapshotOptions new];
options.size = self.mapImageView.frame.size;
options.scale = [[UIScreen mainScreen] scale];
options.region = MKCoordinateRegionMakeWithDistance(coordinate, 2000.f, 2000.f);
MKMapSnapshotter* snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
@antranapp
antranapp / gist:79cd13c2991b8a4d8d9e
Created May 1, 2015 14:36
[iOS] Make status bar in iOS white
// set UIViewControllerBasedStatusBarAppearance to NO in the Info.plist
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
@antranapp
antranapp / gist:cbb6a97ced6b7f487ccf
Last active March 31, 2020 11:02
[iOS] Send notification from appdelegate to view controller
// App Delegate
NSNotificationCenter.defaultCenter().postNotificationName("EventNotification", object: nil, userInfo: ["data": "dummy"])
// View Controller
NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleEventNotification", name: "EventNotification", object: nil)
@antranapp
antranapp / gist:439a0333730c08dffee8
Last active August 29, 2015 14:20
[iOS] Get current root view controller from appDelegate
if let currentViewController = self.window?.rootViewController {
// do something here
}
@antranapp
antranapp / gist:6b6676c246a95ddba915
Last active August 29, 2015 14:20
[iOS] [Swift] Get AppDelegate
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
@antranapp
antranapp / icons
Last active August 29, 2015 14:18 — forked from brutella/icons
#! /bin/sh
function print_example() {
echo "Example"
echo " icons ios ~/AppIcon.png ~/Icons/"
}
function print_usage() {
echo "Usage"
echo " icons <ios|watch|all> in-file.png (out-dir)"