0

RichContentLabel for iOS

-
Full

It's a small browser render engine for browser, using Core-Text without leverage the UIWebView.

  • It has its own smart HTML parser, who can handle all invalid cases, such as unclosed tags and overlapping tags.
  • Fully supports image layout as well as text formatted layout.
  • Useful callback function for link tapping event and image tapping event.

GitHub

 

0

Adjustable Label Category for iOS

-

Adjusting the size of a UILabel is a pain in the back. This category provides a couple of simple methods to make this process less painful. You can "auto adjust" a label provided a minimum size, maximum size or none at all.

Full
0

iOS 5 : UIStepper Control

-

There is a new pre-built control in iOS 5 for incrementing or decrementing a value, UIStepper. The control has two buttons aligned horizontally, one labeled with a plus (+) the other a minus (-).

One nice feature is a continuous option, wherein if the user presses and holds down either +/- button, the stepper value is incremented repeatedly. The longer the button is held down, the faster the increment will occur. Also, you can have the increment value wrap around when a range of values is specified, for example, if you set min and max to 0 and 99 respectively, when the value reaches 99, the next value will be 0 (and vice-versa).

Below is a screenshot that shows the output of the example code below:

Below is a short code example showing the various properties available in UIStepper:

  1.   // Create a label to show the value in the stepper
  2.   label = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 100, 30)];
  3.   [label setTextColor:[UIColor whiteColor]];
  4.   [label setBackgroundColor:[UIColor clearColor]];
  5.   [label setTextAlignment:UITextAlignmentLeft];
  6.   [label setText: @"Quantity:"];
  7.   [[self view] addSubview:label];
  8.  
  9.   // Frame defines location, size values are ignored
  10.   UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(120, 20, 0, 0)];    
  11.  
  12.   // Set action target and action for a particular value changed event
  13.   [stepper addTarget:self action:@selector(stepperPressed:) forControlEvents:UIControlEventValueChanged];
  14.  
  15.   // Set min and max
  16.   [stepper setMinimumValue:0];
  17.   [stepper setMaximumValue:99];
  18.  
  19.   // Value wraps around from minimum to maximum
  20.   [stepper setWraps:YES];
  21.  
  22.   // If continuos (default), changes are sent for each change in stepper,
  23.   // otherwise, change event occurs once user lets up on button
  24.   [stepper setContinuous:NO];
  25.  
  26.   // To change the increment value for each step
  27.   // (default is 1)
  28.   [stepper setStepValue:10];
  // Create a label to show the value in the stepper
  label = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 100, 30)];
  [label setTextColor:[UIColor whiteColor]];
  [label setBackgroundColor:[UIColor clearColor]];
  [label setTextAlignment:UITextAlignmentLeft];
  [label setText: @"Quantity:"];
  [[self view] addSubview:label];

  // Frame defines location, size values are ignored
  UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(120, 20, 0, 0)];    

  // Set action target and action for a particular value changed event
  [stepper addTarget:self action:@selector(stepperPressed:) forControlEvents:UIControlEventValueChanged];

  // Set min and max
  [stepper setMinimumValue:0];
  [stepper setMaximumValue:99];

  // Value wraps around from minimum to maximum
  [stepper setWraps:YES];

  // If continuos (default), changes are sent for each change in stepper,
  // otherwise, change event occurs once user lets up on button
  [stepper setContinuous:NO];

  // To change the increment value for each step
  // (default is 1)
  [stepper setStepValue:10];
1

Small feature with UIlabel

-

Add framework QuartzCore

  1. #import <QuartzCore/QuartzCore.h>
  2.  
  3. UILabel *label = [[UILabel alloc] init];
  4. [label setTextColor:[UIColor whiteColor]];
  5. [label setBackgroundColor:[UIColor darkGrayColor]];
  6.  
  7. [[label layer] setBorderWidth:2];
  8. [[label layer] setCornerRadius:15];
  9. [[label layer] setBorderColor:[UIColor whiteColor].CGColor];
  10.  
  11. [label setAlpha:0.8];
  12. [label setTextAlignment:UITextAlignmentCenter];
  13. [label setFrame:CGRectMake(0, 0, 220, 50)];
  14. [label setText:@"Loading..."];
  15. [label setCenter:window.center];
  16. [window addSubview:label];
#import <QuartzCore/QuartzCore.h>

UILabel *label = [[UILabel alloc] init];
[label setTextColor:[UIColor whiteColor]];
[label setBackgroundColor:[UIColor darkGrayColor]];

[[label layer] setBorderWidth:2];
[[label layer] setCornerRadius:15];
[[label layer] setBorderColor:[UIColor whiteColor].CGColor];

[label setAlpha:0.8];
[label setTextAlignment:UITextAlignmentCenter];
[label setFrame:CGRectMake(0, 0, 220, 50)];
[label setText:@"Loading..."];
[label setCenter:window.center];
[window addSubview:label];

Result: