Posts

[iOS] Custom back button with back gesture

Image
When I want to change the default iOS back button, I need to hide the default back button. This causes the back gesture is also disabled. Therefore, I need to keep the back gesture and make the change. To make these happen, I do steps: Disable the default back button Set the new back button to left bar item Enable the navigation interaction gesture for back gesture Here is the codes (Swift 5) class MyViewController: UIGestureRecognizerDelegate { self.navigationItem.hidesBackButton = true let image = UIImage(systemName: "chevron.backward") let backBarItem = UIBarButtonItem(image: image, style: .plain, target: nil, action: nil) self.navigationItem.leftBarButtonItem = backBarItem self.navigationController?.interactivePopGestureRecognizer?.delegate = self func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool { return true } }

[ROM] Samsung S7 Stock Firmware BRI (Taiwan台灣)

Latest ROM: G930FXXU1DQEU Download: https://kfhost.net/tpl/firmwares.php?record=B7E6DE774E3811E7963AFA163EE8F90B Reference: http://doc.samsungmobile.com/sm-g930f/bri/doc.html https://read01.com/4aoznd.html

[Google Cloud] Upload Cron using Eclipse

1. Create cron.xml and put it on src/main/webapp/WEB-INF: <? xml version = "1.0" encoding = "UTF-8" ?> <cronentries>   <cron>     <url> /tasks/summary </url>     <target> beta </target>     <description> daily summary job </description>     <schedule> every 24 hours </schedule>   </cron> </cronentries> 2. And change pom.xml to: <plugin> <groupId>com.google.cloud.tools</groupId> <artifactId>appengine-maven-plugin</artifactId> <version>${appengine.maven.plugin.version}</version> <configuration>            <deployables>              <param>target/appengine-staging/WEB-INF/appengine-generated/cron.yaml</param>            </deployables>                  </configuration> </plugin>   Note that cron.yaml is the output staging of cron.xml when

[iOS] NSString to hex value

+ (UIColor*)colorFromHex:(NSString*)hexString { // https://github.com/timd/UIColor-HexValues hexString = [hexString stringByReplacingOccurrencesOfString:@"#" withString:@""]; if ([hexString length] == 3) { hexString = [NSString stringWithFormat:@"%@%@%@%@%@%@", [hexString substringWithRange:NSMakeRange(0, 1)],[hexString substringWithRange:NSMakeRange(0, 1)], [hexString substringWithRange:NSMakeRange(1, 1)],[hexString substringWithRange:NSMakeRange(1, 1)], [hexString substringWithRange:NSMakeRange(2, 1)],[hexString substringWithRange:NSMakeRange(2, 1)]]; } if ([hexString length] != 6) { return nil; } // Brutal and not-very elegant test for non hex-numeric characters NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[^a-fA-F|0-9]" options:0 error:NULL]; NSUInteger match = [regex numbe

[iOS] Making fancy view with border, corner and shadow

Image
self.imageView.layer.borderColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1].CGColor; self.imageView.layer.borderWidth = 1; self.imageView.layer.cornerRadius = 3.0; self.imageView.layer.masksToBounds = YES; self.imageView.layer.shouldRasterize = YES; self.imageView.layer.rasterizationScale = [UIScreen mainScreen].scale; self.imageViewBG.layer.shadowOffset = CGSizeMake(1, 1); self.imageViewBG.layer.shadowRadius = 1; self.imageViewBG.layer.shadowOpacity = 0.1; self.imageViewBG.layer.cornerRadius = 3.0; self.imageViewBG.layer.masksToBounds = NO; self.imageViewBG.layer.shouldRasterize = YES; self.imageViewBG.layer.rasterizationScale = [UIScreen mainScreen].scale; UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.imageViewBG.bounds cornerRadius:3.0]; self.imageViewBG.layer.shadowPath = path.CGPath;

[iOS] How to get top most view controller?

+ (UIViewController *)topViewController { return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController]; } + (UIViewController *)topViewController:(UIViewController *)rootViewController { if (rootViewController.presentedViewController == nil) { return rootViewController; } if ([rootViewController.presentedViewController isKindOfClass:[UINavigationController class]]) { UINavigationController *navigationController = (UINavigationController *)rootViewController.presentedViewController; UIViewController *lastViewController = [[navigationController viewControllers] lastObject]; return [self topViewController:lastViewController]; } UIViewController *presentedViewController = (UIViewController *)rootViewController.presentedViewController; return [self topViewController:presentedViewController]; } + (UINavigationController *)navigationController { UIViewController *topViewController = [self topVi