Skip to content

Instantly share code, notes, and snippets.

View heliang219's full-sized avatar

heliang heliang219

View GitHub Profile
来源:https://www.jianshu.com/p/27dbe24e8771
/**
百度坐标转高德坐标
@param glat 纬度
@param glon 经度
@return 数组【转换后的纬度,转换后的经度】
*/
+ (NSArray *)bd09llToGCJLat:(double)glat lon:(double)glon {
@heliang219
heliang219 / Constants.h
Created December 9, 2019 02:03 — forked from ChrisRisner/Constants.h
GeoDemo-ios3
@interface Constants : NSObject
#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
extern NSString *kGetPOIUrl;
extern NSString *kGetSASUrl;
extern NSString *kAddPOIUrl;
extern NSString *kContainerName;
@end
@heliang219
heliang219 / UILabel+Link.m
Created December 9, 2019 01:55 — forked from yycking/UILabel+Link.m
Make a clickable link in an UILabel
@heliang219
heliang219 / UILabelLayoutSideBySide.m
Created December 6, 2019 09:29 — forked from dhl613/UILabelLayoutSideBySide.m
UILabel 并排 自适应 显示
“Content Hugging Priority”,也叫内容紧靠优先级(小名:别扯我),该优先级越高,这越晚轮到被拉伸。
“Content Compression Resistance Priority”,也叫内容压缩阻力优先级(小名:别挤我),该优先级越高,则越晚轮到被压缩。
// ⤴️原文: https://www.jianshu.com/p/a4b8e0c8e68d
// 紧靠能力 优先级越低 内容显示得越完整 反之,内容被省略
[self.nameLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[self.priceLabel setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
@heliang219
heliang219 / rect.m
Created December 6, 2019 09:21 — forked from hanfengs/rect.m
[计算UILabel中text的rect] 计算UILabel中text的rect #UILable
// 过期的方法
CGSize titleSize = [self.evaluationModel.subjectInfoModel.stems sizeWithFont:KFont_Bold(18) constrainedToSize:CGSizeMake(kMainScreenWidth - LRMragin * 2, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
//现在的方法
CGRect rect = [self.lbl_en.text boundingRectWithSize:CGSizeMake(kMainScreenWidth - LRMragin * 2, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: self.lbl_en.font} context:nil];
// YYLable获取文本高度
-(CGFloat)getMessageHeight:(NSString *)mess andLabel:(YYLabel *)lb{
@heliang219
heliang219 / EYUtils.h
Created December 6, 2019 09:21 — forked from erkanyildiz/EYUtils.h
Utilities for Cocoa
// erkanyildiz
// 20190328-1159+0900
//
// EYUtils.h
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#ifndef DEBUG_MODE
#define DEBUG_MODE 1
@heliang219
heliang219 / gist:fd02e6255b9f4a3d00cc489914fd0959
Created December 6, 2019 09:15 — forked from hanfengs/gist:4540f0c8e46070caeedeea575e17abb0
[Label显示不同颜色] UILabel show different colors,根据range给的位置,让范围内的Label文字设置颜色 #Label
[self returnColorString:@"hello, i am xiao qu" WithRange:@"7 7,9 10,17 18"];//, 9 10
self.dialogLab.attributedText = [self returnColorString:resultDic.refText WithRange:resultDic.scoreInfo];
- (NSMutableAttributedString *)returnColorString:(NSString *)oldString WithRange:(NSString *)range{
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:oldString];
NSArray *arr = [range componentsSeparatedByString:@","];
for (NSString *rang in arr) {
@heliang219
heliang219 / IPInsetLabel.h
Created December 6, 2019 09:10
IPInsetLabel: a simple UILabel subclass that adds padding insets and auto-height-resizing
//
// IPInsetLabel.h
// Instapaper
//
// Created by Marco Arment on 7/23/11.
// Copyright 2011 Instapaper LLC, released to the public domain.
//
#import <UIKit/UIKit.h>
@heliang219
heliang219 / textHeight.m
Created December 2, 2019 03:55 — forked from brennanMKE/textHeight.m
Text Height in Objective-C for NSString and NSAttributedString
- (CGFloat)heightForAttributedString:(NSAttributedString *)text maxWidth:(CGFloat)maxWidth {
if ([text isKindOfClass:[NSString class]] && !text.length) {
// no text means no height
return 0;
}
NSStringDrawingOptions options = NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading;
CGSize size = [text boundingRectWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX) options:options context:nil].size;
@heliang219
heliang219 / ColorHelper.h
Created December 2, 2019 03:53 — forked from hmcfletch/ColorHelper.h
A bunch of objective-c color helpers
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
// generate a UIColor from rgb and alpha values
#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define RGB(r, g, b) RGBA(r, g, b, 1.0)
// generate a UIColor
#define GRAYSCALEA(rgb, a) RGBA(rgb, rgb, rgb, a)
#define GRAYSCALE(rgb) GRAYSCALEA(rgb, 1.0)
// generate a UIColor from a hex and an alpha value