把该文件拷贝到.m文件中就能够方便的查找
/Users/ms/Library/Developer/Xcode/UserData/CodeSnippets
#pragma mark - Xcode快捷键
Control + A:移动光标到行首
Control + E:移动光标到行末
Control + D:删除光标右边的字符
Control + K:删除本行
Command + ->:移动到行尾
#pragma mark - 本地化
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud setObject:@"hehe" forKey:@"a"];
[ud synchronize];
NSString *str = [ud objectForKey:@"a"];
#pragma mark - 通知
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"111", @"aaa", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"FM90" object:self.textView.text userInfo:dic];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(listenUp:) name:@"FM90" object:nil];
- (void)listenUp:(NSNotification *)sender
{
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"FM90" object:nil];
}
#pragma mark - 获取程序文件相关文件夹
NSString * homeDirectory = NSHomeDirectory();
NSString * appPath = [[NSBundle mainBundle] bundlePath];
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * path = [paths objectAtIndex:0];
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
path = [paths objectAtIndex:0];
paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
path = [paths objectAtIndex:0];
#pragma mark - 手势
UITouch *momo = [touches anyObject];
if ([momo.view isKindOfClass:[UIImageView class]]) {
[self.view bringSubviewToFront:momo.view];
_tempPoint = [momo locationInView:self.view];
}
momo.tapCount
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapCR:)];
[view addGestureRecognizer:tapGR];
UIPanGestureRecognizer *panGR = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGR:)];
UIPinchGestureRecognizer *pinchGR = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGR:)];
UIRotationGestureRecognizer *rotationGR = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGR:)];
UILongPressGestureRecognizer *longPressGR = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressGR:)];
UISwipeGestureRecognizer *swipeGR = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGR:)];
swipeGR.direction = UISwipeGestureRecognizerDirectionUp;
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGR:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
- (void)swipeGR:(UISwipeGestureRecognizer *)swipeGR
{
CGRect frame = swipeGR.view.frame;
if (swipeGR.direction == UISwipeGestureRecognizerDirectionUp) {
frame.size.height += 10;
}
if (swipeGR.direction & UISwipeGestureRecognizerDirectionLeft) {
frame.size.height -= 10;
}
}
- (void)longPressGR:(UILongPressGestureRecognizer *)longPressGR
{
if (longPressGR.state == UIGestureRecognizerStateBegan)
}
- (void)rotationGR:(UIRotationGestureRecognizer *)rotationGR
{
rotationGR.view.transform = CGAffineTransformRotate(rotationGR.view.transform, rotationGR.rotation);
rotationGR.rotation = 0;
}
- (void)pinchGR:(UIPinchGestureRecognizer *)pinchGR
{
pinchGR.view.transform = CGAffineTransformScale(pinchGR.view.transform, pinchGR.scale, pinchGR.scale);
pinchGR.scale = 1.0;
}
- (void)panGR:(UIPanGestureRecognizer *)panGR
{
CGPoint point = [panGR translationInView:self.view];
panGR.view.center = CGPointMake(panGR.view.center.x + point.x, panGR.view.center.y + point.y);
[panGR setTranslation:CGPointMake(0, 0) inView:self.view];
}
- (void)tapCR:(UITapGestureRecognizer *)tagRG
{
[self.view bringSubviewToFront:tagRG.view];
}
#pragma mark - 图片截取
- (UIImage *)clipImage:(UIImage *)image inRect:(CGRect)rect
{
CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, rect);
UIImage *subImage = [UIImage imageWithCGImage:imageRef];
return subImage;
}
#pragma mark - 计算字符串尺寸
CGSize size = [str boundingRectWithSize:CGSizeMake(width - 5, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:self.label.font, NSFontAttributeName, nil] context:nil].size;
CGRect frame = self.label.frame;
frame.size.width = size.width + 5;
frame.size.height = size.height + 5;
self.label.frame = frame;
#pragma mark - 动画
#pragma mark -简单动画
[UIView animateWithDuration:2 animations:^{
bigView.frame = frame;
}];
[UIView animateWithDuration:2 animations:^{
bigView.frame = frame;
} completion:^(BOOL finished) {
NSLog(@"动画完毕以后的回调=%d",finished);
}];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView commitAnimations];
bigView.autoresizesSubviews = YES;
smallView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
#pragma mark -基础动画
CABasicAnimation *ani = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
ani.fromValue = @0;
ani.toValue = @M_PI;
ani.duration = 2;
ani.repeatCount = 10;
ani.autoreverses = YES;
[view.layer addAnimation:ani forKey:@"aaa"];
[longPressGR.view.layer removeAnimationForKey:@"aaa"];
#pragma mark -转场动画
CATransition *tt = [CATransition animation];
tt.duration = 2;
tt.subtype = kCATransitionFromBottom;
kCATransitionFromRight
kCATransitionFromLeft
kCATransitionFromTop
kCATransitionFromBottom
tt.type = kCATransitionMoveIn;
tt.type = @"rotate";
[self.navigationController.view.layer addAnimation:tt forKey:nil];
[self.navigationController pushViewController:dvc animated:NO];
#pragma mark - UIApplication
openURL:
● UIApplication有个功能⼗十分强⼤大的openURL:⽅方法 - (BOOL)openURL:(NSURL*)url;
● openURL:⽅方法的部分功能有
➢ 打电话
UIApplication *app = [UIApplication sharedApplication]; [app openURL:[NSURL URLWithString:@"tel://10086"]];
➢ 发短信
[app openURL:[NSURL URLWithString:@"sms://10086"]];
➢ 发邮件
[app openURL:[NSURL URLWithString:@"mailto://12345@qq.com"]];
➢ 打开⼀一个⺴⽹网⻚页资源
[app openURL:[NSURL URLWithString:@"http://ios.itcast.cn"]];
#pragma mark - UIView
CGRect frame = bigView.frame;
frame.size.width *= 2;
frame.size.height *= 2;
bigView.frame = frame;
bigView.layer.cornerRadius = 150;
bigView.clipsToBounds = YES;
bigView.layer.borderWidth = 2;
bigView.layer.borderColor = [[UIColor blackColor] CGColor];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default"]];
#pragma mark - UILabel
[self.label sizeToFit];
label.font = [UIFont fontWithName:@"Zapfino" size:20];
label.font = [UIFont systemFontOfSize:20];
label.font = [UIFont boldSystemFontOfSize:20];
label.font = [UIFont italicSystemFontOfSize:20];
#pragma mark - UIButton
UIButton *btn = [UIButton buttonWithType:UIButtonTypeInfoDark];
btn.titleLabel.font = [UIFont systemFontOfSize:15];
btn.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
#pragma mark - UIImageView
UIImagePNGRepresentation(_ivView.image)
[_ivView.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
_starsView.contentMode = UIViewContentModeLeft;
_starsView.clipsToBounds = YES;
iv.contentMode = UIViewContentModeScaleAspectFit;
iv.image = [UIImage imageNamed:@"a"];
UIImage *image = [UIImage imageNamed:@"c"];
UIImageView *secondIv = [[UIImageView alloc] initWithImage:image];
iv.animationImages = tempArr;
iv.animationDuration = tempArr.count/10.0f;
iv.animationRepeatCount = 0;
[iv startAnimating];
#pragma mark - UITextFiled
tf.placeholder = @"请输入QQ号";
tf.borderStyle = UITextBorderStyleLine;
tf.background = [UIImage imageNamed:@"tf_bg"];
tf.adjustsFontSizeToFitWidth = YES;
tf.minimumFontSize = 30;
tf.textAlignment = NSTextAlignmentRight;
tf.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
tf.adjustsFontSizeToFitWidth = YES;
tf.minimumFontSize = 30;
tf.textAlignment = NSTextAlignmentRight;
tf.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
tf.clearsOnBeginEditing = YES;
tf.clearButtonMode = UITextFieldViewModeWhileEditing;
tf.secureTextEntry = YES;
tf.keyboardType = UIKeyboardTypeDefault;
tf.returnKeyType = UIReturnKeyNext;
tf.leftView = view;
tf.leftViewMode = UITextFieldViewModeAlways;
tf.inputView = view;
tf.inputAccessoryView = view;
[self.view endEditing:YES];
[self.view resignFirstResponder]
#pragma mark - UIViewController
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self performSegueWithIdentifier:@"PushToCyan" sender:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UIViewController *nextVC = [segue destinationViewController];
nextVC.view.backgroundColor = [UIColor yellowColor];
MovieCell *cell = (id)sender;
NSIndexPath *path = [self.tableView indexPathForCell:cell];
}
UIStoryboard *sd = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sd instantiateViewControllerWithIdentifier:@"Cyan"];
[self.navigationController pushViewController:vc animated:YES];
3-->-[ThirdViewController initWithNibName:bundle:]
3-->-[ThirdViewController viewDidLoad]
3-->-[ThirdViewController viewWillAppear:]
3-->-[ThirdViewController viewDidAppear:]
-[FourthViewController initWithNibName:bundle:]
-[FourthViewController viewDidLoad]
3-->-[ThirdViewController viewWillDisappear:]
-[FourthViewController viewWillAppear:]
3-->-[ThirdViewController viewDidDisappear:]
-[FourthViewController viewDidAppear:]
-[FourthViewController viewWillDisappear:]
3-->-[ThirdViewController dealloc]
-[FourthViewController viewDidDisappear:]
-[FourthViewController dealloc]
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion;
- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion;
#pragma mark - UINavigationController
self.navigationController.navigationBarHidden = NO;
self.navigationController.navigationBar.barTintColor = [UIColor magentaColor];
self.navigationController.navigationBar.tintColor = [UIColor greenColor];
self.navigationController.navigationBar.translucent = NO;
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"aaa"] forBarMetrics:UIBarMetricsDefault];
[UINavigationBar appearance];
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:10], NSFontAttributeName, [UIColor purpleColor], NSForegroundColorAttributeName, nil];
self.navigationItem.titleView = label;
UIBarButtonSystemItemFlexibleSpace,是自带的一种空的item。能够当作占位符用
[[UIImage imageNamed:@"gerenzhuye"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]。去除图片的渲染
UIBarButtonItem *aItem = [[UIBarButtonItem alloc] initWithTitle:@"aItem" style:UIBarButtonItemStylePlain target:self action:@selector(itemClick)];
[aItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:10], NSFontAttributeName, nil] forState:UIControlStateNormal];
self.navigationItem.leftBarButtonItem = aItem;
UIBarButtonItem *bItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"haoyou"] style:UIBarButtonItemStyleDone target:self action:@selector(itemClick)];
UIBarButtonItem *cItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(itemClick)];
UIBarButtonItem *dItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
self.navigationItem.leftBarButtonItem = self.editButtonItem;
#pragma mark - UITabBarController
UITabBarController *tbc = [[UITabBarController alloc] init];
tbc.viewControllers = [NSArray arrayWithObjects:av, bnc, cv, dv, ev, fv, gv, nil];
gv.hidesBottomBarWhenPushed = YES;
UITabBarItem *homeItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:0];
homeNC.tabBarItem = homeItem;
UITabBarItem *loveItem = [[UITabBarItem alloc] initWithTitle:@"love" image:[UIImage imageNamed:@"tab_0"] tag:0];
UITabBarItem *nearlyItem = [[UITabBarItem alloc] initWithTitle:@"nearly" image:[UIImage imageNamed:@"tab2_1"] selectedImage:[UIImage imageNamed:@"tab2_2"]];
UITabBarController.tabBar.tintColor = [UIColor redColor];
UITabBarController.tabBar.barTintColor = [UIColor cyanColor];
UITabBarController.tabBar.backgroundImage = [UIImage imageNamed:@"tabbg"];
[homeItem setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:10] forKey:NSFontAttributeName] forState:UIControlStateNormal];
self.selectedIndex = sender.tag - 100;
#pragma mark - UIScrollView
sv.contentSize = CGSizeMake(480, 480);
sv.contentOffset = CGPointMake(20, 20);
sv.showsHorizontalScrollIndicator = NO;
sv.showsVerticalScrollIndicator = NO;
sv.bounces = NO;
self.automaticallyAdjustsScrollViewInsets = NO;
sv.minimumZoomScale = 0.5;
sv.maximumZoomScale = 2;
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return [scrollView viewWithTag:1];
}
#pragma mark - UIPageControl
UIPageControl *pc = [[UIPageControl alloc] initWithFrame:CGRectMake(100, 450, 0, 0)];
[pc sizeForNumberOfPages:5];
pc.numberOfPages = 5;
pc.currentPageIndicatorTintColor = [UIColor redColor];
pc.pageIndicatorTintColor = [UIColor greenColor];
pc.userInteractionEnabled = NO;
#pragma mark - UITableView
[_myTableView registerClass:[BookCell class] forCellReuseIdentifier:@"cell"];
[_myTableView registerNib:[UINib nibWithNibName:@"BookCell" bundle:nil] forCellReuseIdentifier:@"cell"];
self.automaticallyAdjustsScrollViewInsets = NO;
_myTableView.separatorColor = [UIColor redColor];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;
#pragma -编辑相关
[_myTableView reloadData];
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[[_dataArr objectAtIndex:indexPath.section] removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
}
if (editingStyle == UITableViewCellEditingStyleInsert) {
Person *person = [[Person alloc] init];
[[_dataArr objectAtIndex:indexPath.section] insertObject:person atIndex:indexPath.row];
[_myTableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
}
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
Person *person = [[_dataArr objectAtIndex:sourceIndexPath.section] objectAtIndex:sourceIndexPath.row];
[[_dataArr objectAtIndex:sourceIndexPath.section] removeObject:person];
[[_dataArr objectAtIndex:destinationIndexPath.section] insertObject:person atIndex:destinationIndexPath.row];
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:YES];
[_myTableView setEditing:editing animated:YES];
}
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
NSMutableArray *titleArr = [NSMutableArray array];
for (int i = 'A'; i <= 'Z'; i++) {
[titleArr addObject:[NSString stringWithFormat:@"%c", i]];
}
return titleArr;
}
#pragma mark - UICollectionView
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
[_myCollection registerClass:[MyCell class] forCellWithReuseIdentifier:@"cell"];
[_myCollection registerClass:[MyView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section;
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
cell.label.text = [NSString stringWithFormat:@"第%d个", indexPath.row];
cell.iconView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg", indexPath.row]];
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView;
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section;
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
MyView *view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header" forIndexPath:indexPath];
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section;
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
#pragma mark - UIToolbar
UIToolbar *tb = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 20, 320, 44)];
[self.view addSubview:tb];
UIBarButtonItem *editBtn =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(editClick:)];
tb.items = @[editBtn, refreshBtn];
#pragma mark - UISearchBar
_sb = [[UISearchBar alloc] initWithFrame:frame];
_myTableView.tableHeaderView = _sb;
_sdc = [[UISearchDisplayController alloc] initWithSearchBar:_sb contentsController:self];
_sdc.delegate = self;
_sdc.searchResultsDataSource = self;
_sdc.searchResultsDelegate = self;
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
[_resultArr removeAllObjects];
for (NSArray *arr in _myDataArr) {
for (NSString *str in arr) {
NSRange range = [str rangeOfString:searchString];
if (range.length > 0) {
[_resultArr addObject:str];
}
}
}
return YES;
}
#pragma mark - 定时器和延时调用
NSTimer *_timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(run) userInfo:nil repeats:YES];
_timer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(update:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSDefaultRunLoopMode];
[_timer invalidate];
[self performSelector:@selector(runLater:) withObject:sender afterDelay:0.5];
#pragma mark - 经常使用基本控件
#pragma mark UISlider
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(40, 60, 240, 90)];
[self.view addSubview:slider];
[slider addTarget:self action:@selector(sliderClick:) forControlEvents:UIControlEventValueChanged];
slider.continuous = NO;
slider.maximumValue = 10;
slider.minimumValue = 0;
slider.value = 5;
slider.maximumTrackTintColor = [UIColor blackColor];
slider.minimumTrackTintColor = [UIColor greenColor];
[slider setThumbImage:[UIImage imageNamed:@"gerenzhuye"] forState:UIControlStateNormal];
#pragma mark UISegmentedControl
UISegmentedControl *segmentControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"111", [[UIImage imageNamed:@"gerenzhuye"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal],@"222", nil]];
segmentControl.frame = CGRectMake(40, 200, 240, 60);
[segmentControl addTarget:self action:@selector(segmentedControlClick:) forControlEvents:UIControlEventValueChanged];
[segmentControl removeSegmentAtIndex:1 animated:YES];
[segmentControl insertSegmentWithTitle:@"333" atIndex:2 animated:YES];
segmentControl.selectedSegmentIndex = 1;
segmentControl.tintColor = [UIColor redColor];
sc.selectedSegmentIndex;
[sc titleForSegmentAtIndex:sc.selectedSegmentIndex];
#pragma mark UISwitch
UISwitch *open = [[UISwitch alloc] initWithFrame:CGRectMake(40, 80, 100, 100)];
open.thumbTintColor = [UIColor redColor];
open.tintColor = [UIColor blackColor];
open.onTintColor = [UIColor blueColor];
open.on = YES;
#pragma mark UIActivityIndicatorView
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[indicator startAnimating];
indicator.center = self.view.center;
indicator.color = [UIColor yellowColor];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
#pragma mark UIWebView
NSURL *url = [NSURL URLWithString:str];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
webView.scalesPageToFit = YES;
- (void)reload;
- (void)stopLoading;
- (void)goBack;
- (void)goForward;
#pragma mark UIStepper
UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(40, 60, 200, 40)];
stepper.stepValue = 30;
stepper.minimumValue = 10;
stepper.maximumValue = 300;
stepper.tintColor = [UIColor redColor];
[stepper setIncrementImage:[UIImage imageNamed:@"haoyou"] forState:UIControlStateNormal];
[stepper setDecrementImage:[UIImage imageNamed:@"liaotian"] forState:UIControlStateNormal];
#pragma mark UIProgressView
UIProgressView *pv = [[UIProgressView alloc] initWithFrame:CGRectMake(20, 300, 280, 80)];
[pv setProgress:(sender.value-10)/290.0 animated:YES];
#pragma mark UIAlertView
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"标题" message:@"信息" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"其它",@"其它2", nil];
[av show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
av.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
#pragma mark UIActionSheet
UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:@"title" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"dt" otherButtonTitles:@"qq", @"weixin", @"weibo", nil];
[as showInView:self.view];