解决:navigation, push出来的view里面的uitextview上面有空白部分;
scroll也从下面开始(上面一段大概navigation bar那么大的空白区域)
self.automaticallyAdjustsScrollViewInsets = NO;
2. 找到commentView的高度约束 并更新宽度
for (NSLayoutConstraint* constraint in commentView.constraints) { if (constraint.firstAttribute == NSLayoutAttributeHeight) { constraint.constant = 1; } }
3. iOS的16进制的颜色代码转换成UIColor
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
4. 添加虚线边框
CAShapeLayer* _border = [CAShapeLayer layer]; _border.strokeColor = [UIColor colorWithRed:67/255.0f green:37/255.0f blue:83/255.0f alpha:1].CGColor; _border.fillColor = nil; _border.lineDashPattern = @[@4, @2]; _border.path = [UIBezierPath bezierPathWithRect:self.addPhotoBtn.bounds].CGPath; _border.frame = self.addPhotoBtn.bounds; [self.addPhotoBtn.layer addSublayer:_border];
5. 设置iosUIView(及其子类)的圆角,需要设置MasksToBounds=yes。
[self.img.layer setMasksToBounds:YES]; [self.img.layer setCornerRadius:self.portraitImg.frame.size.width/2];
6. 如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可(项目需要使用QuartzCore框架)。而若要指定某几个角(小于4)为圆角而别的不变时,这种方法就不好用了。对于这种情况,Stackoverflow上提供了几种解决方案。其中最简单优雅的方案,就是使用UIBezierPath。下面给出一段示例代码。
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)]; view2.backgroundColor = [UIColor redColor]; [self.view addSubview:view2]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)]; CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = view2.bounds; maskLayer.path = maskPath.CGPath; view2.layer.mask = maskLayer;
其中,
byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
指定了需要成为圆角的角。该参数是UIRectCorner类型的,可选的值有:
* UIRectCornerTopLeft
* UIRectCornerTopRight
* UIRectCornerBottomLeft
* UIRectCornerBottomRight
* UIRectCornerAllCorners
从名字很容易看出来代表的意思,使用“|”来组合就好了。
感谢原作者简明扼要的总结!原文地址:http://webfrogs.me/2013/05/22/ios-view-assign-corner-radius/