小编top*_*ide的帖子

UIButton子类 - 设置属性?

我创建了一个UIButton子类,给它一个白色的2px No Radii边框,现在我试图"全局"设置它的字体,字体颜色和背景颜色,具体取决于按钮状态.

字体未设置.颜色或背景颜色也没有.这是怎么回事?这是我的代码.我希望你能帮忙:)

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {

    [[self titleLabel] setFont:[UIFont fontWithName:@"ZegoeUI" size:18]];
    [self setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    if(self.state == UIControlStateHighlighted) {
        [self setBackgroundColor:[UIColor whiteColor]];
    }
    else {
        [self setBackgroundColor:[UIColor blackColor]];
    }
}
return self;
}





// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {

             [self.layer setMasksToBounds:YES];
[self.layer setBorderWidth:2.0];
[self.layer setCornerRadius:0.0];
[self.layer setBorderColor:[[UIColor colorWithWhite:1.0 alpha:1.0] CGColor]];
}
Run Code Online (Sandbox Code Playgroud)

我不认为我做错了什么.我有这个类,并在IB中链接了按钮,并设置类类型...

谢谢, …

xcode objective-c uibutton ios4 ios

8
推荐指数
1
解决办法
6072
查看次数

UICollectionView部分标题闪烁问题

这个帖子(也许是愚蠢的)经过连续8个小时对我的计算机像一些愚蠢的猴子一样g ,,因为UICollectionView在iOS 7上存在问题.

我有子类UICollectionViewFlowLayout为我的UICollectionView dataSource的所有50个部分提供了一个通用的"Section X"(Sticky Header)[其中X是一个数字]标题,这是一个NSArray分区.

- (NSArray *) layoutAttributesForElementsInRect:(CGRect)rect {在我的子类中调用,它确实显示了标题,但仅适用于第一部分.这是非常奇怪的行为.我的期望是:

|S| [CELL] [CELL] |S| [CELL] [CELL] 
|E| [    ] [    ] |E| [    ] [    ] 
|C| [____] [____] |C| [____] [____] 
|T|               |T|
| | [CELL] [CELL] | | [CELL] 
| | [    ] [    ] | | [    ] 
|1| [____] [____] |2| [____]
Run Code Online (Sandbox Code Playgroud)

"SECT 2"是第一个之后的下一个标题,当用户水平滚动时(应用于垂直方向)应该在屏幕上可见,但我得到的是:

|S| [CELL] [CELL] | | [CELL] [CELL] 
|E| [ …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uicollectionview uicollectionviewlayout ios7

4
推荐指数
1
解决办法
1851
查看次数