当前位置: 编程技术>移动开发
本页文章导读:
▪施用TypefaceSpan 使用TypefaceSpan
package de.myproject.text.style;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.text.style.TypefaceSpan;
public class CustomTypefaceSpan extends TypefaceSpan {
.........
▪ UINavigationBar自定义背景以及旋钮(转) UINavigationBar自定义背景以及按钮(转)
UINavigationBar自定义导航栏背景和按钮,完美支持横屏竖屏旋转,视图控制器可以分别使用自己的导航栏此方法可以通过Apple审核,导航上的按钮背景需要做.........
▪ NinePatch图片制造 NinePatch图片制作
左边和上边是要拉伸的地方;
右边和下边是要显示内容的地方。
左边和上边的不能省略,否则程序会出错。
show content可以看见内容的显示区域。
show patches在内容的.........
[1]施用TypefaceSpan
来源: 互联网 发布时间: 2014-02-18
使用TypefaceSpan
package de.myproject.text.style;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.text.style.TypefaceSpan;
public class CustomTypefaceSpan extends TypefaceSpan {
private final Typeface newType;
public CustomTypefaceSpan(String family, Typeface type) {
super(family);
newType = type;
}
@Override
public void updateDrawState(TextPaint ds) {
applyCustomTypeFace(ds, newType);
}
@Override
public void updateMeasureState(TextPaint paint) {
applyCustomTypeFace(paint, newType);
}
private static void applyCustomTypeFace(Paint paint, Typeface tf) {
int oldStyle;
Typeface old = paint.getTypeface();
if (old == null) {
oldStyle = 0;
} else {
oldStyle = old.getStyle();
}
int fake = oldStyle & ~tf.getStyle();
if ((fake & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
}
if ((fake & Typeface.ITALIC) != 0) {
paint.setTextSkewX(-0.25f);
}
paint.setTypeface(tf);
}
}
[2] UINavigationBar自定义背景以及旋钮(转)
来源: 互联网 发布时间: 2014-02-18
UINavigationBar自定义背景以及按钮(转)
UINavigationBar自定义导航栏背景和按钮,完美支持横屏竖屏旋转,视图控制器可以分别使用自己的导航栏
此方法可以通过Apple审核,导航上的按钮背景需要做,否则看起来不那么和之又谐
转自:http://xyyk.iteye.com/blog/739972
UINavigationBar自定义导航栏背景和按钮,完美支持横屏竖屏旋转,视图控制器可以分别使用自己的导航栏
此方法可以通过Apple审核,导航上的按钮背景需要做,否则看起来不那么和之又谐
//CustomNavigationBar.h
@interface UINavigationBar (UINavigationBarCategory)
UIImageView *backgroundView;
- (void)setBackgroundImage:(UIImage*)image;
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
@end
//CustomNavigationBar.m
@implementation UINavigationBar (UINavigationBarCategory)
-(void)setBackgroundImage:(UIImage*)image
{
if(image == nil)
{
[backgroundView removeFromSuperview];
}
else
{
backgroundView = [[UIImageView alloc] initWithImage:image];
backgroundView.tag = 1;
backgroundView.frame = CGRectMake(0.f, 0.f, self.frame.size.width, self.frame.size.height);
backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:backgroundView];
[self sendSubviewToBack:backgroundView];
[backgroundView release];
}
}
//for other views
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
{
[super insertSubview:view atIndex:index];
[self sendSubviewToBack:backgroundView];
}
@end
//YourViewController.m
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController.navigationBar
setBackgroundImage:[UIImage imageNamed:@"navigation_bar_bg.png"]];
}
转自:http://xyyk.iteye.com/blog/739972
[3] NinePatch图片制造
来源: 互联网 发布时间: 2014-02-18
NinePatch图片制作
左边和上边是要拉伸的地方;
右边和下边是要显示内容的地方。
左边和上边的不能省略,否则程序会出错。
show content可以看见内容的显示区域。
show patches在内容的显示区域(content)显示图片要拉伸的块
最新技术文章: