UIButton * btn = [UIButton new];
[btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
//May god have mercy of me
[[btn titleLabel] setFont:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium]];
[btn setTitle:[NSString stringWithFormat:@" %@ ", btnTxt] forState:UIControlStateNormal];
[btn sizeToFit];
[btn setTitle:btnTxt forState:UIControlStateNormal];
Why keep playing with label padding or insets when you can add spaces?
static NSInteger const CBBIndexOne = 1;
static NSInteger const CBBIndexTwo = 2;
static NSInteger const CBBIndexThree = 3;
static NSInteger const CBBIndexFour = 4;
static NSInteger const CBBIndexSix = 6;
static NSInteger const CBBIndexSeven = 7;
static NSInteger const CBBIndexEight = 8;
static NSInteger const CBBRowHeightFifty = 50;
static NSInteger const CBBRowHeightSixtySix = 66;
static NSInteger const CBBRowHeightSixtyTwo = 62;
static NSInteger const CBBRowHeightOneTen = 110;
static NSInteger const CBBRowHeightOneEightEight = 188;
static NSInteger const CBBRowHeightTwoHundred = 200;
static NSInteger const CBBRowHeightThirtySix = 36;
int w = 100;
for (nil; w!=0; nil) {
w -= 1;
//so some shit
}
this code was found in chinese contract work
typedef NS_ENUM(NSUInteger, MyEnum1) {
PackagesNo1 = 1,
PackagesNo2 = 2,
PackagesNo4 = 4,
PackagesNo8 = 8
};
typedef NS_ENUM(NSUInteger, MyEnum2) {
LEVEL0 = 0,
LEVEL1 = 1,
LEVEL2 = 2,
LEVEL3 = 3
};
- (int)packagesNeededForLevel:(int)level {
switch (level) {
case LEVEL0:
return PackagesNo8;
case LEVEL1:
return PackagesNo4;
case LEVEL2:
return PackagesNo2;
case LEVEL3:
return PackagesNo1;
}
}
well done mr junior