Posts

[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...

[iOS] How to open a native app or Appstore from Safari or UIWebView

Image
1. Promoting App Banner: https://developer.apple.com/ library/ios/documentation/ AppleApplications/Reference/ SafariWebContent/ PromotingAppswithAppBanners/ PromotingAppswithAppBanners. html http://stackoverflow.com/ questions/6964515/launching- app-or-app-store-from-safari 2. Take user to Appstore from Safari link: http://applinks.org/ documentation/ https://www. brandbuilderwebsites.com/blog/ 2014/05/01/mobile-app-linking/ https://developers.facebook. com/products/app-links

[iOS] Draw Dashed Border Around View

+ (void)drawDashedBorderAroundView:(UIView *)v cornerRadius:(CGFloat)cornerRadius borderWidth:(CGFloat)borderWidth dashPattern1:(NSInteger)dashPattern1 dashPattern2:(NSInteger)dashPattern2 lineColor:(UIColor*)lineColor { //border definitions // CGFloat cornerRadius = 10; // CGFloat borderWidth = 2; // NSInteger dashPattern1 = 4; // NSInteger dashPattern2 = 8; // UIColor *lineColor = [UIColor grayColor]; CGRect newR = v.frame; newR.origin.x += borderWidth/2; newR.origin.y += borderWidth/2; newR.size.width -= borderWidth; newR.size.height -= borderWidth; v.frame = newR; //drawing CGRect frame = v.bounds; CAShapeLayer *_shapeLayer = [CAShapeLayer layer]; //creating a path CGMutablePathRef path = CGPathCreateMutable(); //drawing a border around a view CGPathMoveToPoint(path, NULL, 0, frame.size.height -...

PowerDirector – Video Editor

Image
  PowerDirector – Video Editor by CyberLink  Well, this app is one of the best video editor for Android. Most functions are almost the same as PowerDirector PC version. You can add any media files, add effects, etc. This app is almost the same as iMovie (by Apple). In other words, this is the " iMovie for Android ". Go try it! Here is the description: CyberLink brings the multi-award winning PowerDirector from PC to Android tablets! The most powerful video editor on the market, PowerDirector gives you the power to create amazing, awesome, engaging videos on-the-go. Import and edit videos, add effects and titles, and export HD video directly to Facebook or YouTube. --- Currently only available for Android 7” tablets and above --- With PowerDirector’s easy-to-use timeline interface, you can quickly create professional, effect rich videos with just a few swipes of your finger. Selecting and importing multiple videos is easy with PowerDirec...

Adjust volume of 16-bits audio buffer

Recently, I found that it is so hard to adjust volume of the audio buffer (yeah... I am new on audio). In this post, I learned how to adjust volume of 16-bits audio buffer easily. Here is the code: private byte[] adjustVolume(byte[] audioSamples, double volume) { byte[] array = new byte[audioSamples.length]; for (int i = 0; i < array.length; i+=2) { // convert byte pair to short short audioSample = (short) ((short) ((audioSamples[i+1] & 0xff) << 8) | (audioSamples[i] & 0xff)); audioSample = (short) (audioSample * volume); // convert back array[i] = (byte) audioSample; array[i+1] = (byte) (audioSample >> 8); } return array; } You can see that the code below is storing audiobuffer using "byte" datatype which is 8-bits datatype. Since our audio buffer is 16-buts datatype, you need to convert it into 16-bits datatype (I used "short") by using shift method (you can find...

Stop ‘Trust This Computer’ Message Pop Up

Image
After updating to iOS 7, many Windows users have reported that they are constantly getting the ‘Trust this computer” message pop up even after selecting ‘Trust’ when plugging in their iPhone or iPad. Here is a list of common fixes to resolve this annoying message. The first step you should try is to update your iTunes. Fix#1 1. Go to Control Panel > Hardware & Sounds > Device Manager 2. Right-click the Apple device > Properties > ‘Hardware’ tab > Properties > ‘Driver’ tab > Update Driver.. 3. Search for the driver in “C:\Program Files\Common Files\Apple\Mobile Device Support\Drivers” 4. The driver should be named ‘usbaapl64′ Fix #2 1. Go to Control Panel > Hardware & Sounds > Device Manager 2. Right-click the Apple device > Properties > ‘Hardware’ tab > Properties > ‘Driver’ tab > Disable 3. The pop up should not appear anymore and the device will charge while plugged in Fix #3 1. Control Panel > Uninstall a Program...