ios UI 구현 기술
13185 단어 ios
NSString *key = [[NSString alloc] initWithData:[NSData dataWithBytes:(unsigned char []){0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x61, 0x72} length:9] encoding:NSASCIIStringEncoding];
key = @"statusBar";//
id object = [UIApplication sharedApplication];
UIView *statusBar;
if ([object respondsToSelector:NSSelectorFromString(key)]) {
statusBar = [object valueForKey:key];
}
statusBar.transform = CGAffineTransformMakeTranslation(self.paneView.frame.origin.x, self.paneView.frame.origin.y);
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
UIImage *icon = [[UIImage imageNamed:@"jinghua-selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *unIcon = [[UIImage imageNamed:@"jinghua"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[nc.tabBarItem setFinishedSelectedImage:icon withFinishedUnselectedImage:unIcon];
} else {
[nc.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"jinghua-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"jinghua"]];
}
[nc.tabBarItem setTitle:NSLocalizedString(@" ", nil)];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithWhite:113./255 alpha:1], UITextAttributeTextColor, nil]
forState:UIControlStateNormal];
//Item
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithWhite:56./255 alpha:1], UITextAttributeTextColor, nil]
forState:UIControlStateSelected];
#import <objc/runtime.h>
@implementation UIControl (userInteractoinEdgeInsets)
static char topNameKey;
static char rightNameKey;
static char bottomNameKey;
static char leftNameKey;
-(void)setUserInteractionEdgeInsets:(UIEdgeInsets)edgeInsets{
objc_setAssociatedObject(self, &topNameKey, [NSNumber numberWithFloat:edgeInsets.top], OBJC_ASSOCIATION_COPY_NONATOMIC);
objc_setAssociatedObject(self, &rightNameKey, [NSNumber numberWithFloat:edgeInsets.right], OBJC_ASSOCIATION_COPY_NONATOMIC);
objc_setAssociatedObject(self, &bottomNameKey, [NSNumber numberWithFloat:edgeInsets.bottom], OBJC_ASSOCIATION_COPY_NONATOMIC);
objc_setAssociatedObject(self, &leftNameKey, [NSNumber numberWithFloat:edgeInsets.left], OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (CGRect)enlargedRect
{
NSNumber* topEdge = objc_getAssociatedObject(self, &topNameKey);
NSNumber* rightEdge = objc_getAssociatedObject(self, &rightNameKey);
NSNumber* bottomEdge = objc_getAssociatedObject(self, &bottomNameKey);
NSNumber* leftEdge = objc_getAssociatedObject(self, &leftNameKey);
if (topEdge && rightEdge && bottomEdge && leftEdge)
{
return CGRectMake(self.bounds.origin.x - leftEdge.floatValue,
self.bounds.origin.y - topEdge.floatValue,
self.bounds.size.width + leftEdge.floatValue + rightEdge.floatValue,
self.bounds.size.height + topEdge.floatValue + bottomEdge.floatValue);
}
else
{
return self.bounds;
}
}
- (UIView*)hitTest:(CGPoint) point withEvent:(UIEvent*) event
{
CGRect rect = [self enlargedRect];
if (CGRectEqualToRect(rect, self.bounds))
{
return [super hitTest:point withEvent:event];
}
return CGRectContainsPoint(rect, point) ? self : nil;
}
@end
@implementation UITabBarController (dynamic)
-(void)deleteChildViewController:(UIViewController*)controller{
if ([self.viewControllers containsObject:controller]){
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.viewControllers];
[viewControllers removeObject:controller];
self.viewControllers = [NSArray arrayWithArray:viewControllers];
}
}
-(void)insertChildViewController:(UIViewController*)controller atIndex:(NSInteger)index{
if (index >=0 && index <=self.viewControllers.count && ![self.viewControllers containsObject:controller]) {
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.viewControllers];
if (!viewControllers) {
viewControllers = [NSMutableArray array];
}
[viewControllers insertObject:controller atIndex:index];
self.viewControllers = [NSArray arrayWithArray:viewControllers];
}
}
@end
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, nil]];
if ([[UIDevice currentDevice].systemVersion floatValue]<7.0) {
[self.navigationBar setTintColor:[UIColor colorWithRed:0.0 green:194./255 blue:196./255 alpha:1]];
}else{
[self.navigationBar setBarTintColor:[UIColor colorWithRed:0.0 green:194./255 blue:196./255 alpha:1]];
}
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:language, nil]
forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
-(void)viewDidLayoutSubviews
{
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
}
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Swift의 패스트 패스Objective-C를 대체하기 위해 만들어졌지만 Xcode는 Objective-C 런타임 라이브러리를 사용하기 때문에 Swift와 함께 C, C++ 및 Objective-C를 컴파일할 수 있습니다. Xcode는 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.