iOS筆記(常用的一些知識點)

來源:互聯網
上載者:User

iOS筆記(常用的一些知識點)

這是我在公司做項目時,順便做的一些筆記.......

//1.iphone開發--改變UIPageControl裡的小點的顏色

pageControl.currentPageIndicatorTintColor = [UIColor blackColor];

pageControl.pageIndicatorTintColor = [UIColor grayColor];

 

//2.ios如何讓狀態列變成白色的

[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent];

如果不行,請在info.plist裡面添加 View controller-based status bar appearance NO

可以參考http://beyondvincent.com/blog/2013/11/03/120-customize-navigation-status-bar-ios-7/

 

//3.如:修改導覽列預設標題"憶雲美印"的顏色和字型

self.title=@"憶雲美印";

self.navigationController.navigationBar.titleTextAttributes=@{UITextAttributeTextColor:[UIColor whiteColor],UITextAttributeFont:[UIFont boldSystemFontOfSize:20]};

 

//4.給label設定圓角

label.layer.borderWidth=1.0f;

label.layer.cornerRadius=5.0f;

 

//5.手動旋轉狀態列必須實現下面的方法

- (BOOL)shouldAutorotate

{

return NO;

}

- (NSUInteger)supportedInterfaceOrientations

{

return UIInterfaceOrientationMaskPortrait;

}

 

//6.如何設定只能豎屏顯示

修改info.plist裡面supportedInterfaceOrientations設定item為portrait就可以了,這個設定為全域.

 

//7.利用UIColor展現#f6f6f6這個傳統色彩轉換為十進位f6為240

則UIColor *color=[UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1];

 

//8.建立類目,延展,協議,空檔案

cmd+n 選擇ios Source裡面的objective-c File -> File Type的類型(類目,延展,協議,空檔案)

 

//9.把視圖轉換為圖片

//把視圖轉換為圖片

UIGraphicsBeginImageContext(oppositeImageView.bounds.size);

[oppositeImageView.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *oppositeImg=UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

 

//10.實現圖片視圖的拖動效果

- (void)viewDidLoad {

[super viewDidLoad];

//建立圖片視圖

imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 150)];

imageView.userInteractionEnabled=YES;

imageView.image=[UIImage imageNamed:@"ad_1"];

 

//平移手勢

UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];

[imageView addGestureRecognizer:pan];

[self.view addSubview:imageView];

}

//平移手勢的拖動事件

- (void)panAction:(UIPanGestureRecognizer *)pan

{

CGPoint point=[pan translationInView:self.view];

pan.view.center=CGPointMake(pan.view.center.x+point.x, pan.view.center.y+point.y);

[pan setTranslation:CGPointZero inView:self.view];

}

//11.圖片可以響應事件,如 UITextView添加到圖片可以進行拖動.

backgrondImage.userInteractionEnabled=YES;

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.