iOS开发 UIlabel 文字两边对齐 思路:算出每个字符之间的宽度 给UIlabel添加一个分类即可,代码如下: * 必须导入这个头文件:CoreText/CoreText.h - (void)changeAlignmentRightandLeft{ CGRect textSize = [sel ...
分类:
其他好文 时间:
2017-11-10 12:53:37
阅读次数:
181
let button = UIButton(type:.system); button.frame = CGRect.init(x:100,y:150,width:160,height:30); button.setTitle("SwiftBtton", for: .normal); button. ...
分类:
编程语言 时间:
2017-10-17 15:20:37
阅读次数:
198
+ (CGRect )scaleImage:(UIImage *)image toSize:(CGRect)newSize { float actualHeight = image.size.height; float actualWidth = image.size.width; float im... ...
分类:
移动开发 时间:
2017-09-30 14:56:07
阅读次数:
233
直接上代码: import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let btn = UIButton.init(frame: CGRect.i ...
分类:
编程语言 时间:
2017-09-27 17:37:43
阅读次数:
942
1 。首先新建UIView一个类 2 在UIView一个类.m 里面追加 - (instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { self.clearsContextBe ...
分类:
移动开发 时间:
2017-09-22 17:48:34
阅读次数:
474
对于iOS常见的绘图效果都是可以用贝塞尔曲线来实现的,贝塞尔的使用分为两种情况1,在UIView的 draw(_ rect: CGRect) 函数中是用,这个函数中默认存在上下文环境,所以可以直接显示 override func draw(_ rect: CGRect) { let point = ...
分类:
其他好文 时间:
2017-08-02 23:31:26
阅读次数:
167
分页控制器子标题颜色渐变,重写UILable的drawRect,对UILable进行颜色填充。 #import "HMLabel.h" @implementation HMLabel //重绘UILabel - (void)drawRect:(CGRect)rect { [super drawRec ...
分类:
其他好文 时间:
2017-08-01 12:35:15
阅读次数:
230
#import "AFNetworkReachabilityManager.h" - (BOOL)isNetWorkReachable{ __block CGRect rect = _nonNetworkLabel.frame; //这里的声明前面加__block。作用是在块里能够改动rect的值; ...
分类:
其他好文 时间:
2017-07-27 18:17:32
阅读次数:
161
仅做记录,一个函数和字符串之间的互相转换 方法如下: 例子: 结构体转字符串: 字符串转 结构体: ...
分类:
移动开发 时间:
2017-07-21 12:30:07
阅读次数:
184
NSLog(@"%@",NSStringFromCGRect(pickerView.frame)); 或者 CFShow(NSStringFromCGRect(pickerView.frame)); 打印 CGSize : NSLog(@"%@",NSStringFromCGSize(someCG ...
分类:
移动开发 时间:
2017-07-18 18:48:25
阅读次数:
174