原创 iOS開發筆記之漸隱提示框
繼承自UIView,兩個方法: // 初始化 - (instancetype)init { if (self = [super init]) { self.backgroundColor = [UIColor b
原创 iOS開發筆記之設置self.view原點爲導航欄左下角
self.edgesForExtendedLayout =UIRectEdgeNone;
原创 iOS開發筆記之代碼控制屏幕旋轉
// 能否自動旋轉 -(BOOL)shouldAutorotate{ return NO; } // 支持的屏幕方向 -(UIInterfaceOrientationMask)supportedInterfaceOrientat
原创 iOS開發筆記之獲取App版本號、獲取iOS系統版本
// 獲取App版本號 NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; NSString *appVersion = [infoDictiona
原创 iOS開發筆記之設置鍵盤爲UIDatePicker
// 創建datePicker UIDatePicker *datePicker = [[UIDatePicker alloc] init]; // 本地化 // self.datePicker.locale
原创 UISearchBar的部分自定義設置
// searchBar背景顏色 searchBar.barTintColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; // 設置searchBar中textFiel
原创 iOS開發筆記之元素爲字典的數組,按元素的value排序
NSSortDescriptor *des = [NSSortDescriptor sortDescriptorWithKey:@"key" ascending:YES]; NSArray *sortedArr = [array sort
原创 iOS可複用控件之滾動按鈕組
GitHub地址:https://github.com/runThor/HTScrollButton 效果: 控件內部有一個ScrollView,按鈕都加在ScrollView上。 實現: ScrollView類: // HTBut
原创 iOS小樂子之買多少注彩票才能中超級大樂透頭獎
GitHub地址:https://github.com/runThor/HTLottery 實現: // 大樂透的玩法:前區號碼範圍1-35,隨機選取5個不重複的數;後區號碼範圍1-12,隨機選取2個不重複的數,頭獎即所有號碼完
原创 iOS可複用控件之分段滾動控件HTSegmentedScrollView
分段滾動頁面是一個比較常見的需求,我把我的實現方式封裝了一下,方便以後重複使用。實現效果:GitHub地址:https://github.com/runThor/HTSegmentedScrollView使用方式非常簡單,添加segmen
原创 iOS開發筆記之Timestamp時間戳與各地區實際時間格式的相互轉換
// 實際時間轉爲時間戳 - (NSString *)translateTimestampFormat:(NSString *)realtime { NSString *template =@"yy/MM/dd HH:mm";
原创 iOS開發筆記之設置view部分圓角
// 例:設置左下角爲圓角 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCorn
原创 iOS可複用控件之錶盤
GitHub地址:https://github.com/runThor/HTDial 效果: 實現: // 實際應用中,整個區域經常需要分爲偏低區域、適中區域、偏高區域等不同的劃分區域,要用不同的顏色標識,這裏我們默認劃分低、中、高三
原创 UIStatusBar和UINavigationBar的自定義設置
// statusBar樣式 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];// 字體明暗 [self.navigat
原创 iOS開發筆記之常用宏定義
// 單例 #define SINGLETON_FOR_CLASS(classname) \ \ + (classname*) shareInstance \ { \ static dispatch_once_t pred = 0