iPhone Development

add news feed

post a story

In most of the iOS applications we will encounter the situation of having a single UILabel with different colors, different font style and sizes. Before iOS 6, there are no official properties or classes for achieving this feature. But i...
In most of the iOS applications we will encounter the situation of having a single UILabel with different colors, different font style and sizes. Before iOS 6, there are no official properties or classes for achieving this feature. But in iOS 6, apple added the extra power to UILabel called attributedText. Means we can achieve this feature using NSAttributedString class in iOS. In this tutorial I will explain how to get the multiple color, font and sizes for the single UILabel in iOS 6 and its earlier versions. Open Xcode and proceed with the single view application template. In AppDelegate.m file modify the code such that ViewController becomes the root view of the navigation controller by adding the following code. UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:self.viewController]; self.window.rootViewController = navController; Now Open ViewController.xib file, change its orientation property to landscape and add the UILabel, UIButton outlets. We make this app to work only for landscape mode by selecting the options shown in the following figure. You will get this in the summary tab of main project target. Connect the outlets with the associated objects in ViewController class by adding the following code. @interface ViewController : UIViewController @property (nonatomic, strong) IBOutlet UILabel *attrLabel; - (IBAction)next:(id)sender; @end In viewDidLoad method of ViewController.m file, add the following lines of code. self.title = @"For iOS 6 & later"; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String"]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,5)]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)]; [str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:30.0] range:NSMakeRange(0, 5)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(6, 12)]; [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:30.0] range:NSMakeRange(19, 6)]; attrLabel.attributedText = str; In this code we are performing actions such as giving different colors, fonts to different words using NSAttributedString method addAttrubute:value:range. Now compile and run the code, the following screen will appear. The above code will be valid only for iOS 6 and later versions. If we want to implement the same feature in earlier versions, we need to use some third party classes like TTTAttributedLabel. We can find this class at https://github.com/mattt/TTTAttributedLabel Download the content in the link and add it to your project. Also add CoreText.framework to the project. Now compile and run, make sure there are no errors. To implementing the UILabel with multi color and font feature using TTTAttributedLabel class, we need a new controller class. Add a new class and name it as NextViewController. Now add the following lines of code in next: action method of ViewController.m file. NextViewController *nextController = [[NextViewController alloc]initWithNibName:@"NextViewController" bundle:nil];[self.navigationController pushViewController:nextController animated:YES]; Open NextViewController.xib file, add the UILabel outlet and change its class name as TTTAttributedLabel. Also link it with the associated object in NextViewController.h file. In viewDidLoad method of NextViewController.m file, add the following lines of code. self.title = @"For iOS 5.1 & earlier"; NSString *text =
10 12 days ago
Design,Featured iPhone Development Resources,Objective-C Last month I mentioned an open source library allowing you to create various user interface elements with a flat style. While being able to generate different elements is nice Top...
Design,Featured iPhone Development Resources,Objective-C Last month I mentioned an open source library allowing you to create various user interface elements with a flat style. While being able to generate different elements is nice Tope over at the App Design Vault has created a set of templates for commonly created screens with the flat minimalistic look . The templates include login screens, user profile screens, activity screens, settings, and menu sidebar screens. Here are some images from the download page showing some of the templates in action: You can find the free flat UI design resources over on the App Design Vault here. A very cool set of resources if you’re looking to give an app that flat look. The resources come complete in an Xcode project. Be the first to comment... Related Posts:iOS Library For Creating Great Looking Customizable Flat User Interface ElementsTutorial: Extensive Guide On How To Make Xcode 4 File TemplatesOver 1000 Free Vector Components For Creating Mockups In KeynoteFree iOS Design Templates For Easy App Design With The Sketch AppOpen Source iOS UI Control For Customizable Flat Style Alert Views With Custom Transitions Original article: Free iOS UI Templates With A Sleek Minimalist Flat Style©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.
25 12 days ago
@jazzychad Here's a video taken at the scene
@jazzychad Here's a video taken at the scene
about 3 hours ago
@sdw Here's the video taken 3-5 minutes after the crash. Note how far away the engine is at the end.
@sdw Here's the video taken 3-5 minutes after the crash. Note how far away the engine is at the end.
about 4 hours ago
@subamu @shahm0nsterr True,
@subamu @shahm0nsterr True,
about 4 hours ago
@AlwayzFree
@AlwayzFree
about 4 hours ago
During Monday’s Hangout Ed Maurina showed off a new memory monitoring tool that show realtime information about device memory, display memory, and frame per second while your app is running. The memory meter can be added to your pr...
During Monday’s Hangout Ed Maurina showed off a new memory monitoring tool that show realtime information about device memory, display memory, and frame per second while your app is running. The memory meter can be added to your projects with two lines of code and it comes with full documentation. You can download super meter from the Roaming Gamer website. Thanks Ed! Watch the full Hangout for more geek fun. Thank you for watching, we’ll see you on next week’s Corona Geek hangout! Remember To Subscribe Download the Corona Geek podcast on iTunes Listen to Corona Geek on Stitcher Subscribe to Corona Geek on YouTube
about 5 hours ago
Featured iPhone Development Resources,iOS UI Controls,iPad,iPhone,Objective-C Last week I mentioned a project allowing you to use iOS 7 style interface elements with minimal changes to UIKit based code in iOS 5 or 6 called UI7Kit and pr...
Featured iPhone Development Resources,iOS UI Controls,iPad,iPhone,Objective-C Last week I mentioned a project allowing you to use iOS 7 style interface elements with minimal changes to UIKit based code in iOS 5 or 6 called UI7Kit and previously mentioned a nice library for creating flat style UI components (that don’t mimic the look of iOS 7). Here’s another great open source project for creating flat UI components – inspired by iOS 7 called Flat UI by Piotr Bernad.    Flat UI is inspired by iOS 7 and if you’re looking to flatten out an apps UI to match iOS 7 you may want to have a look. There are a number of user interface elements included, and you can easily customize the colors, sizes, and fonts. Here’s a set of images from the readme showing FlatUI in action: You can find FlatUI on Github here. Between the different libraries this should help those looking to give their apps a flat look. Be the first to comment... Related Posts:New Open Source Project Bringing iOS 7 Style To iOS 5 and 6 UIKit InterfacesOpen Source iOS UI Control For Customizable Flat Style Alert Views With Custom TransitionsFree iOS UI Templates With A Sleek Minimalist Flat StyleiOS Library For Creating Great Looking Customizable Flat User Interface ElementsOpen Source iOS UI Control Providing Evernote Folder Style Navigation Original article: Open Source Control Providing iOS 7 Inspired Flat UI Elements©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.
about 15 hours ago
Featured iPhone Development Resources,iOS Development Libraries,Objective-C,Open Source iOS Libraries And Tools One of the interesting features of iOS 7 that has been widely talked about on various tech sites is the tilt based parallax ...
Featured iPhone Development Resources,iOS Development Libraries,Objective-C,Open Source iOS Libraries And Tools One of the interesting features of iOS 7 that has been widely talked about on various tech sites is the tilt based parallax effect of the home screen that adds depth to the user interface. Here’s a submission from Arnaud Coomans providing an Objective-C library that allows you to easily recreate this effect using your own image. With the library you can fine tune how the image reacts to tilt, set up a delegate to run code when the parallax effect starts/ends, and automatically refocus the parallax view. Here’s an animation from the readme showing the example in action: You can find Parallax on Github here. Definitely a nifty effect for adding depth to an app.  Thanks to Arnaud for the submission. Be the first to comment... Related Posts:Open Source iOS Control For Quickly Adding A Parallax Scrolling Effect To Your UIViewsOpen Source Library For Adding A Parallax Scrolling Effect To A Stylizable UITableViewOpen Source: Source Code To Tilt Monster (Doodle Dash) Game Created With The Corona SDKExample: How To Implement A Real-Time Green Screen Effect On iOS Using OpenGL ESOpen Source iOS Control Providing Keylines That Adjust Based On Device Tilt Like The Music App Original article: Library Allowing You To Emulate The iOS 7 Home Screen Image Parallax Tilt Effect©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.
1 day ago
Today’s guest tutorial comes to you courtesy of Christer Eckermann, the co-founder of Snuti, a small Norway-based indie game start-up. Snuti consists of two University graduates, Clare Falconer and Christer Eckermann, trying to mak...
Today’s guest tutorial comes to you courtesy of Christer Eckermann, the co-founder of Snuti, a small Norway-based indie game start-up. Snuti consists of two University graduates, Clare Falconer and Christer Eckermann, trying to make their independent game development dream come true. They will release their first commercial game this summer and are hoping to deliver a cute and unique experience. You can follow Snuti on Facebook and Twitter. Making Games Run Smoothly With Delta Time One method of animating, moving, and timing things in games is to programmatically change certain values on each frame update. However, if you update with a specific value every frame, for example, moving an object down one pixel every frame, then, with fluctuating frame rates, the speed of this action may seem inconsistent to the player. In that case, the player will experience both a choppy frame rate and a fluctuating game speed. But if your game already runs smoothly, so why should you worry about it? Well, even if it does run smoothly, there are constant small changes in the frame rate. To compensate for this, you can use delta time. This helps ensure that your game runs more stable on older devices.  More significantly, frame rate often drops noticeably when the device is displaying notifications or when your game is processing something heavy. In my opinion, all games should use delta time, no matter the size and depth, if you want the game speed to appear consistent. What is Delta Time? The word delta means “change,” and thus delta time means “change in time.” In games, delta time is a compensation value. In practical use, the delta time value is multiplied by values that are affected by time. When the frame rate is lower, affected values increase to compensate for the time gap, or decrease for fast frame rates. If your frame rate is consistently 60 frames per second, then the delta time value is 1.0, effectively enacting no change. If the frame rate drops to 30 fps, then the delta time increases to 2.0, making all values twice the size to compensate for the slower frame rate. Where to Use Delta Time For a moving object which changes position, rotation, or scale. Manual countdowns in the frame update, as you may want these countdowns to reflect time instead of how many frames have passed. Most values which are changed over time. The Delta Time Function The function below calculates the delta time value which you can use in your frame update function. Corona games can run at two different frames-per-second rates: 30 and 60. The function below is set up for 60 fps, but you can adjust it for a 30 fps game by changing (1000/60) to (1000/30). local runtime = 0 local function getDeltaTime() local temp = system.getTimer() --Get current game time in ms local dt = (temp-runtime) / (1000/60) --60fps or 30fps as base runtime = temp --Store game time return dt end If you print out the delta time value for each frame, it will look something like this: 0.95916, 1.00638, 0.924, 0.9667, ... The value will be very close to 1.0 when the game runs at 59-61 frames a second, but it will change more significantly if the frame rate fluctuates more severely. Implementing Delta Time Assuming you have the above function in your game code, implementing delta time shouldn’t change your existing code too much. However, just be careful to only multiply it by changing values, not the entire value, as illustrated in the code below. --A box object local box = display.newRect( 50, 0, 100, 100 ) --Frame update function local function frameUpdate() --Delta Time value local dt = getDeltaTime() --Move your box, 5 pixels with delta compensation box:translate( 0, 5.0*dt ) --For rotation... --INCORRECT: do not multiply with the entire value! --box.rotation = (box.rotation+1) * dt --CORRECT: only multiply with the changing value: box.rotation = box.rotation + (1*dt)
1 day ago