iOS set CornerRadius

0 意見


CALayer * btnlayer = [SumbitButton layer];
[btnlayer setMasksToBounds:YES];
[btnlayer setCornerRadius:5.0];
[btnlayer setBorderWidth:1.0];
[btnlayer setBackgroundColor:[submitColor CGColor]];
[btnlayer setBorderColor:[highlightColor CGColor]];


be sure to #import <QuartzCore/QuartzCore.h>

iOS get navigation bar tint color

0 意見


CGFloat c[4];
UIColor *color = self.navigationController.navigationBar.tintColor;
[color getRed:&c[0] green:&c[1] blue:&c[2] alpha:&c[3]];

iOS replace string

0 意見

NSString *str = @"apple banana cherry"
str = [str stringByReplacingOccurrencesOfString:@" " withString:@","];

// str => apple,banana,cherry

iOS AlertView

0 意見

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title"
                                                message:@"message"
                                               delegate:nil
                                      cancelButtonTitle:@"OK"
                                      otherButtonTitles:nil];
        
        [alert show];

iOS string token

0 意見


NSString *resp = @"one,two,three";

if(resp != NULL)
{
    NSArray *token = [resp componentsSeparatedByString: @","];
    // token[0]="one"   token[1]="two"  token[2]="three"
}

Android pass variable by intent

0 意見

 // put to
 Intent intent = new Intent();
 intent.setClass(this, Next.class);
 intent.putExtra("addr", "new address to next intent");
 startActivity(intent);

 // get from
 Intent getfrom = getIntent();
 String dest = getfrom.getStringExtra("addr");

iOS xCode hotkey

0 意見







Android get absolute path of the app

0 意見

String path = getApplicationContext().getFilesDir().getAbsolutePath();

Android remove view from table

0 意見

If you got the error message, the specified child already has a parent. you must call removeview() on the child's parent first. The solution is remove the child from parent view.

TableLayout table = (TableLayout)findViewById(R.id.tableLayout); TableRow tr = (TableRow) table.getChildAt(table.getChildCount()-1); table.removeView(tr);
// if you don't know the parent, get the parent view first. ViewGroup parentViewGroup = (ViewGroup)tr.getParent(); parentViewGroup.removeView(tr);