天天看點

一些開發内容,做個備注

總有一些友善的開發方式或者通用的方法,還總記不住,老是去翻以前的項目,做個備份。(慢慢補充)

1、view控件加邊框

profileImageButton = [UIButton buttonWithType:UIButtonTypeCustom];

[profileImageButton.layer setMasksToBounds:YES];

[profileImageButton.layer setCornerRadius:4.0]; //設定矩形四個圓角半徑

[profileImageButton.layer setBorderWidth:1.0];   //邊框寬度

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){225.0/255.0, 225.0/255.0, 225.0/255.0, 1.0 });

[profileImageButton.layer setBorderColor:colorref];//邊框顔色 

單獨設定圓角

[iconImage.layer setCornerRadius:4.0];

[iconImage setClipsToBounds:YES];

2、時區傳回格式為數字(-12—+12)   

-(NSString *)getTimeZone{ 

    NSString *zone = [[NSTimeZone systemTimeZone] description];//Europe/Berlin//       America/New_York//   Asia/Harbin

                                                                               //這三個可以用來測試exp:NSString *zone = [[NSTimeZone timeZoneWithName:@"America/New_York"] description];

    NSString *time = [[zone componentsSeparatedByString:@"offset "] objectAtIndex:1];

    int inv = [time intValue];

    int result = inv / (60 * 60);

    if (result>0) {

        return [NSString stringWithFormat:@"+%d", result];

    }

    return [NSString stringWithFormat:@"%d", result];

}

一些開發内容,做個備注