Skip to content

Instantly share code, notes, and snippets.

View IvanovDeveloper's full-sized avatar

Andrew Ivanov IvanovDeveloper

  • Ukraine
View GitHub Profile
@IvanovDeveloper
IvanovDeveloper / ConfigureGradientForView
Created March 30, 2016 08:51
Configure gradient for view
- (void)configureGradientView:(UIView *)aView {
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = aView.bounds;
gradient.colors = @[(id)[UIColor colorWithWhite:0.f alpha:0.01f].CGColor,
(id)[UIColor colorWithWhite:0.f alpha:0.02f].CGColor,
(id)[UIColor colorWithWhite:0.f alpha:0.03f].CGColor,
(id)[UIColor colorWithWhite:0.f alpha:0.2f].CGColor,
(id)[UIColor colorWithWhite:0.f alpha:0.3f].CGColor,
@IvanovDeveloper
IvanovDeveloper / iOS - Font - Log All Fonts
Last active January 31, 2021 17:32
log all the fonts available to your app in the console
//Obhective-C
for (NSString* family in [UIFont familyNames])
{
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(@" %@", name);
}
}
@IvanovDeveloper
IvanovDeveloper / viewWillTransitionToSize
Created July 11, 2016 14:39
Как определить момент до поворота экрана и после поворота экрана
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
// Stuff you used to do in willRotateToInterfaceOrientation would go here.
// If you don't need anything special, you can set this block to nil.
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
__weak __typeof(self) weakSelf = self;
__strong __typeof(weakSelf) strongSelf = weakSelf;
//objective-c
-//random bool
srand(time(0));
int randomval = rand() % 2;
apiCall.shouldFailToLoad = (BOOL)randomval;
NSLog(@"Should fail to load:%d", apiCall.shouldFailToLoad);
-//random integer
arc4random_uniform(upper_bound)
//Create cell from storyboard
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PlayerCell"];
//Create cell programmatically
static NSString *cellIdentifier = @"cellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
#import <CoreLocation/CoreLocation.h>
@interface LocationManager () <CLLocationManagerDelegate>
@property (nonatomic, strong) CLLocationManager *locationManager;
@end
@implementation
- (id)init
self = [super init];
@IvanovDeveloper
IvanovDeveloper / RedirectToAppScriptExample
Created February 13, 2017 09:54
Для того чтобы открыть iOS приложение по ссылке необходимо реализовать скрипт который открывает другую ссылку с которой связано приложение.
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
setTimeout(function () {
//This link will be changed later. If application not installed at device, this link for opening the app in appstore.
window.location = "https://itunes.apple.com/us/app/swelp-focus-on-the-core/id1148572155?l=ru&ls=1&mt=8";
}, 25);
//Link for product should be "mainAndMe://products/[current product id]";
//Link for store should be "mainAndMe://stores/[current store id]";
@IvanovDeveloper
IvanovDeveloper / RedirectToAppScriptExample
Created February 13, 2017 09:54
Для того чтобы открыть iOS приложение по ссылке необходимо реализовать скрипт который открывает другую ссылку с которой связано приложение.
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
setTimeout(function () {
//This link will be changed later. If application not installed at device, this link for opening the app in appstore.
window.location = "https://itunes.apple.com/us/app/swelp-focus-on-the-core/id1148572155?l=ru&ls=1&mt=8";
}, 25);
//Link for product should be "mainAndMe://products/[current product id]";
//Link for store should be "mainAndMe://stores/[current store id]";
@IvanovDeveloper
IvanovDeveloper / RedirectToAppScriptExample
Last active February 13, 2017 10:12
Для того чтобы открыть iOS приложение по ссылке необходимо реализовать скрипт который открывает другую ссылку с которой связано приложение.
// Этот скрипт нужно реализовать в двух местах.
// 1. При регистрации когда происходит запрос confirmation_token
// 2. При восстановлении пароля
// P.S. Эти скрипты я проверял, они рабочие. Главнное чтобы можно было генерировать необходимую ссылку
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
setTimeout(function () {
// Если приложение не установленно выполняеться эта функция. Она перенаправляет в аппстор для скачивания необходимого приложения.